Mixed effects models - random effects by participant ID
library(readxl)
## Warning: package 'readxl' was built under R version 4.1.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.1.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.1.3
## Warning: package 'tibble' was built under R version 4.1.3
## Warning: package 'tidyr' was built under R version 4.1.3
## Warning: package 'readr' was built under R version 4.1.3
## Warning: package 'purrr' was built under R version 4.1.3
## Warning: package 'stringr' was built under R version 4.1.3
## Warning: package 'forcats' was built under R version 4.1.3
## Warning: package 'lubridate' was built under R version 4.1.3
## -- Attaching core tidyverse packages ------------------------ tidyverse 2.0.0 --
## v forcats 1.0.0 v readr 2.1.4
## v ggplot2 3.4.4 v stringr 1.5.0
## v lubridate 1.9.2 v tibble 3.2.1
## v purrr 1.0.1 v tidyr 1.3.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## i Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(ggplot2)
library(broom.mixed)
library(lme4)
## Warning: package 'lme4' was built under R version 4.1.3
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 4.1.3
##
## Attaching package: 'Matrix'
##
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
library(lmerTest)
## Warning: package 'lmerTest' was built under R version 4.1.3
##
## Attaching package: 'lmerTest'
##
## The following object is masked from 'package:lme4':
##
## lmer
##
## The following object is masked from 'package:stats':
##
## step
library(performance)
Home videos:
anything else to account for R and left turn vidoes? Try running on just right and just left turn data?
Other test more appropriate for home video? outcomes not normally distributed and QQ plots look bad…..
Improve metric - re-run delta pixel eye to foot?
Additional analysis with just log
Dropped rows with any missing video metrics for adj vs unadj metrics
Should this be done before univariate steps?
EDSS + T25FW: sensitivity analysis - dateDiff from video walking +- 90 days, +- 30 days
Interaction? Full model with interaction full_model <- lmer(response ~ factor1 * factor2 + (1 | subject), data = mydata)
Reduced model without the interaction reduced_model <- lmer(response ~ factor1 + factor2 + (1 | subject), data = mydata)
anova(reduced_model, full_model)
# analysis folder
analysis_version <- '005'
# video metric folder version
metrics_version <- '004'
output_dir <- file.path("C:/Users/mmccu/Box/MM_Personal/5_Projects/BoveLab/3_Data_and_Code/gait_bw_zeno_home_analysis",
analysis_version,
"003_mixed_effects_video_metric_vs_outcomes")
# create output folder if it doesn't already exist
if (file.exists(output_dir) == FALSE){
dir.create(output_dir)
}
All videos included in analysis.
Each row = 1 video
# Preferred Walking Speed
zeno_pws_path <- file.path("C:/Users/mmccu/Box/MM_Personal/5_Projects/BoveLab/3_Data_and_Code/gait_bw_zeno_home_analysis",
metrics_version,
"000_merged_cleaned_data",
"zv_bw_merged_gait_vertical_PWS_1_clean.csv")
zeno_pws_df <- read.csv(zeno_pws_path)
table(zeno_pws_df$task_pose)
##
## gait_vertical_PWS_1
## 224
str(zeno_pws_df)
## 'data.frame': 224 obs. of 79 variables:
## $ X : int 0 1 3 4 5 6 7 8 10 11 ...
## $ video_id_date_name_pose_zv : chr "gait_vertical_PWS_1_BW-0002_2022_09_12" "gait_vertical_PWS_1_BW-0002_2023_09_12" "gait_vertical_PWS_1_BW-0004_2022_09_19" "gait_vertical_PWS_1_BW-0006_2022_09_26" ...
## $ id_date_pose_zv : chr "BW-0002\\2022_09_12" "BW-0002\\2023_09_12" "BW-0004\\2022_09_19" "BW-0006\\2022_09_26" ...
## $ task_pose_zv : chr "gait_vertical_PWS_1" "gait_vertical_PWS_1" "gait_vertical_PWS_1" "gait_vertical_PWS_1" ...
## $ frames_per_second_pose_zv : int 25 30 30 30 30 30 30 30 30 30 ...
## $ total_video_duration_sec_pose_zv : num 42.8 46.6 30.4 24.4 27.3 ...
## $ delta_pix_h_rel_median_pose_zv : num 0.15 0.22 0.37 0.36 0.26 NA 0.34 NA 0.28 0.27 ...
## $ walking_segmets_n_pose_zv : num NA 2 NA 2 4 2 2 4 3 3 ...
## $ walking_segments_duration_mean_pose_zv : num NA 5.62 NA 4.65 3.95 4.48 4.55 6.94 3.6 4.79 ...
## $ walking_segments_duration_median_pose_zv : num NA 5.62 NA 4.65 4.05 4.48 4.55 6.88 3.93 5 ...
## $ stride_time_mean_sec_pose_zv : num NA 1.47 NA 1.15 1.17 ...
## $ stride_time_median_sec_pose_zv : num NA 1.5 NA 1.17 1.17 ...
## $ stride_time_std_pose_zv : num NA 0.254 NA 0.134 0.116 0.09 0.048 0.081 0.166 0.143 ...
## $ stride_time_cv_pose_zv : num NA 17.26 NA 11.71 9.84 ...
## $ stride_time_max_pose_zv : num NA 1.87 NA 1.37 1.47 ...
## $ stride_time_min_pose_zv : num NA 1.033 NA 0.967 0.933 ...
## $ mean_cadence_step_per_min_pose_zv : num NA 91.5 NA 112 92.3 ...
## $ stride_width_mean_cm_pose_zv : num NA 12.5 NA 9.2 10 ...
## $ stride_width_median_cm_pose_zv : num NA 13.5 NA 11.2 11.7 ...
## $ stride_width_std_pose_zv : num NA 4.21 NA 5.52 4.43 ...
## $ stride_width_cv_pose_zv : num NA 33.8 NA 60 44.2 ...
## $ stride_width_max_pose_zv : num NA 16.9 NA 18.8 16.2 ...
## $ stride_width_min_pose_zv : num NA 0.932 NA 0.63 1.131 ...
## $ foot1_gait_cycle_time_mean_pose_zv : num NA 1.23 NA NA 1.23 ...
## $ foot1_stance_time_mean_pose_zv : num NA 1.033 NA NA 0.833 ...
## $ foot1_stance_per_mean_pose_zv : num NA 83.8 NA NA 67.6 ...
## $ foot1_swing_time_mean_pose_zv : num NA 0.2 NA NA 0.4 0.333 NA 0.367 0.383 NA ...
## $ foot1_swing_per_mean_pose_zv : num NA 16.2 NA NA 32.4 ...
## $ foot1_ini_double_support_time_mean_pose_zv : num NA 0.367 NA NA 0.233 0.233 NA 0.233 0.117 NA ...
## $ foot1_term_double_support_time_mean_pose_zv: num NA 0.2 NA NA 0.5 0.2 NA 0.133 0.15 NA ...
## $ foot1_tot_double_support_time_mean_pose_zv : num NA 0.567 NA NA 0.733 0.433 NA 0.367 0.267 NA ...
## $ foot1_double_support_per_mean_pose_zv : num NA 45.9 NA NA 59.5 ...
## $ foot1_single_support_time_mean_pose_zv : num NA 0.467 NA NA 0.1 0.333 NA 0.367 0.433 NA ...
## $ foot1_single_support_per_mean_pose_zv : num NA 37.84 NA NA 8.11 ...
## $ walk_segment_pose_zv : num NA 1 NA NA 2 1 NA 0 0 NA ...
## $ foot1_pose_zv : chr "" "right" "" "" ...
## $ id_video : chr "BW-0002" "BW-0002" "BW-0004" "BW-0006" ...
## $ visit_date_video : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ bw_id : chr "BW-0002" "BW-0002" "BW-0004" "BW-0006" ...
## $ trialdate : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ visit_date : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ demoEHR_DiseaseDuration : num 0 1 17 17 7 8 25 26 30 31 ...
## $ clean_sex : chr "Male" "Male" "Female" "Female" ...
## $ clean_race : chr "Other" "Other" "White" "White" ...
## $ clean_ethnicity : chr "Hispanic Or Latino" "Hispanic Or Latino" "Not Hispanic Or Latino" "Not Hispanic Or Latino" ...
## $ demoEHR_Age : num 37 37 46 65 53 53 60 60 71 71 ...
## $ bingoEHR_DX_MS.DX : chr "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "PPMS (Primary-progressive Multiple Sclerosis)" ...
## $ bingoEHR_EDSS_measure_value : num 3.5 3 3 3 3 2 3 3 3.5 3.5 ...
## $ msfcEHR_T25FW.SPEED.AVG : num 5 6.1 4.3 4.6 4.6 4.9 3.7 4.4 5.2 6.1 ...
## $ FW_cadencestepsminmean : num 113 103 134 120 124 ...
## $ FW_singlesupportmean : num 36.8 34.7 39.8 36.5 38.1 ...
## $ FW_singlesupportratiolr : num 1.09 1.11 1.02 1.07 1.01 ...
## $ FW_stridetimeseccv : num 4.01 5.92 3.1 3.12 3.77 ...
## $ FW_stridetimesecmean : num 1.061 1.158 0.891 0.99 0.959 ...
## $ FW_stridewidthcmmean : num 14.76 13.91 7.1 7.55 11.94 ...
## $ FW_stridewidthcmsd : num 4.97 3.75 4.08 3.19 3.08 ...
## $ FW_totaldsupportmean : num 27.3 30.5 20.4 26.9 24 ...
## $ FW_totaldsupportratiolr : num 0.985 1.003 0.992 0.984 1.046 ...
## $ FW_velocitycmsecmean : num 145 119 197 133 164 ...
## $ PWS_cadencestepsminmean : num 79.4 74.6 100.2 107.3 90.2 ...
## $ PWS_singlesupportmean : num 30.5 30.8 37.1 34.8 32.6 ...
## $ PWS_singlesupportratiolr : num 1.2 1.07 1.14 1.1 1.11 ...
## $ PWS_stridetimeseccv : num 24.5 21.4 23.5 15.5 36.1 ...
## $ PWS_stridetimesecmean : num 1.51 1.61 1.19 1.12 1.33 ...
## $ PWS_stridewidthcmmean : num 16.63 12.11 2.31 8.48 11.43 ...
## $ PWS_stridewidthcmsd : num 11.47 5.32 7.82 16.29 13.71 ...
## $ PWS_totaldsupportmean : num 35.4 35.2 36.4 30.4 30.1 ...
## $ PWS_totaldsupportratiolr : num 1.091 0.912 1.216 0.995 1.077 ...
## $ PWS_velocitycmsecmean : num 66.1 74.1 101.2 94.7 78 ...
## $ redcap_event_name : chr "Brainwalk: Baseline visit (Arm 1: Baseline visit)" "Year 2 Visit (Arm 1: Baseline visit)" "Brainwalk: Baseline visit (Arm 1: Baseline visit)" "Brainwalk: Baseline visit (Arm 1: Baseline visit)" ...
## $ demographic_diagnosis : chr "MS" "MS" "MS" "MS" ...
## $ bingoEHR_Vitals_height.in. : num 66 NA 67.5 67 NA 68 65 66 63 63 ...
## $ bingoEHR_first_MS.DX : chr "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "PPMS (Primary-progressive Multiple Sclerosis)" ...
## $ edss_severity_num : num 2 2 2 2 2 1 2 2 2 2 ...
## $ edss_severity_cat : chr "moderate" "moderate" "moderate" "moderate" ...
## $ t25fw_group_num : num 1 2 1 1 1 1 1 1 1 2 ...
## $ t25fw_group_cat : chr "under_6" "6_to_8" "under_6" "under_6" ...
## $ race_ethnicity_clean : chr "Hispanic or Latino" "Hispanic or Latino" "White Not Hispanic" "White Not Hispanic" ...
## $ ms_dx_condensed : chr "RRMS" "RRMS" "RRMS" "Progressive MS" ...
zeno_pws_df <- zeno_pws_df %>%
mutate_at(c("video_id_date_name_pose_zv", "id_date_pose_zv", "task_pose_zv",
"id_video", "bw_id", "clean_sex", "bingoEHR_DX_MS.DX",
"demographic_diagnosis", "race_ethnicity_clean",
"race_ethnicity_clean", "ms_dx_condensed",
"redcap_event_name"),
as.factor)
str(zeno_pws_df)
## 'data.frame': 224 obs. of 79 variables:
## $ X : int 0 1 3 4 5 6 7 8 10 11 ...
## $ video_id_date_name_pose_zv : Factor w/ 224 levels "gait_vertical_PWS_1_BW-0002_2022_09_12",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ id_date_pose_zv : Factor w/ 224 levels "BW-0002\\2022_09_12",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ task_pose_zv : Factor w/ 1 level "gait_vertical_PWS_1": 1 1 1 1 1 1 1 1 1 1 ...
## $ frames_per_second_pose_zv : int 25 30 30 30 30 30 30 30 30 30 ...
## $ total_video_duration_sec_pose_zv : num 42.8 46.6 30.4 24.4 27.3 ...
## $ delta_pix_h_rel_median_pose_zv : num 0.15 0.22 0.37 0.36 0.26 NA 0.34 NA 0.28 0.27 ...
## $ walking_segmets_n_pose_zv : num NA 2 NA 2 4 2 2 4 3 3 ...
## $ walking_segments_duration_mean_pose_zv : num NA 5.62 NA 4.65 3.95 4.48 4.55 6.94 3.6 4.79 ...
## $ walking_segments_duration_median_pose_zv : num NA 5.62 NA 4.65 4.05 4.48 4.55 6.88 3.93 5 ...
## $ stride_time_mean_sec_pose_zv : num NA 1.47 NA 1.15 1.17 ...
## $ stride_time_median_sec_pose_zv : num NA 1.5 NA 1.17 1.17 ...
## $ stride_time_std_pose_zv : num NA 0.254 NA 0.134 0.116 0.09 0.048 0.081 0.166 0.143 ...
## $ stride_time_cv_pose_zv : num NA 17.26 NA 11.71 9.84 ...
## $ stride_time_max_pose_zv : num NA 1.87 NA 1.37 1.47 ...
## $ stride_time_min_pose_zv : num NA 1.033 NA 0.967 0.933 ...
## $ mean_cadence_step_per_min_pose_zv : num NA 91.5 NA 112 92.3 ...
## $ stride_width_mean_cm_pose_zv : num NA 12.5 NA 9.2 10 ...
## $ stride_width_median_cm_pose_zv : num NA 13.5 NA 11.2 11.7 ...
## $ stride_width_std_pose_zv : num NA 4.21 NA 5.52 4.43 ...
## $ stride_width_cv_pose_zv : num NA 33.8 NA 60 44.2 ...
## $ stride_width_max_pose_zv : num NA 16.9 NA 18.8 16.2 ...
## $ stride_width_min_pose_zv : num NA 0.932 NA 0.63 1.131 ...
## $ foot1_gait_cycle_time_mean_pose_zv : num NA 1.23 NA NA 1.23 ...
## $ foot1_stance_time_mean_pose_zv : num NA 1.033 NA NA 0.833 ...
## $ foot1_stance_per_mean_pose_zv : num NA 83.8 NA NA 67.6 ...
## $ foot1_swing_time_mean_pose_zv : num NA 0.2 NA NA 0.4 0.333 NA 0.367 0.383 NA ...
## $ foot1_swing_per_mean_pose_zv : num NA 16.2 NA NA 32.4 ...
## $ foot1_ini_double_support_time_mean_pose_zv : num NA 0.367 NA NA 0.233 0.233 NA 0.233 0.117 NA ...
## $ foot1_term_double_support_time_mean_pose_zv: num NA 0.2 NA NA 0.5 0.2 NA 0.133 0.15 NA ...
## $ foot1_tot_double_support_time_mean_pose_zv : num NA 0.567 NA NA 0.733 0.433 NA 0.367 0.267 NA ...
## $ foot1_double_support_per_mean_pose_zv : num NA 45.9 NA NA 59.5 ...
## $ foot1_single_support_time_mean_pose_zv : num NA 0.467 NA NA 0.1 0.333 NA 0.367 0.433 NA ...
## $ foot1_single_support_per_mean_pose_zv : num NA 37.84 NA NA 8.11 ...
## $ walk_segment_pose_zv : num NA 1 NA NA 2 1 NA 0 0 NA ...
## $ foot1_pose_zv : chr "" "right" "" "" ...
## $ id_video : Factor w/ 154 levels "BW-0002","BW-0004",..: 1 1 2 3 4 4 5 5 6 6 ...
## $ visit_date_video : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ bw_id : Factor w/ 154 levels "BW-0002","BW-0004",..: 1 1 2 3 4 4 5 5 6 6 ...
## $ trialdate : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ visit_date : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ demoEHR_DiseaseDuration : num 0 1 17 17 7 8 25 26 30 31 ...
## $ clean_sex : Factor w/ 3 levels "Female","Male",..: 2 2 1 1 1 1 2 2 1 1 ...
## $ clean_race : chr "Other" "Other" "White" "White" ...
## $ clean_ethnicity : chr "Hispanic Or Latino" "Hispanic Or Latino" "Not Hispanic Or Latino" "Not Hispanic Or Latino" ...
## $ demoEHR_Age : num 37 37 46 65 53 53 60 60 71 71 ...
## $ bingoEHR_DX_MS.DX : Factor w/ 5 levels "MS, Subtype Not Specified",..: 4 4 4 2 4 4 5 5 4 4 ...
## $ bingoEHR_EDSS_measure_value : num 3.5 3 3 3 3 2 3 3 3.5 3.5 ...
## $ msfcEHR_T25FW.SPEED.AVG : num 5 6.1 4.3 4.6 4.6 4.9 3.7 4.4 5.2 6.1 ...
## $ FW_cadencestepsminmean : num 113 103 134 120 124 ...
## $ FW_singlesupportmean : num 36.8 34.7 39.8 36.5 38.1 ...
## $ FW_singlesupportratiolr : num 1.09 1.11 1.02 1.07 1.01 ...
## $ FW_stridetimeseccv : num 4.01 5.92 3.1 3.12 3.77 ...
## $ FW_stridetimesecmean : num 1.061 1.158 0.891 0.99 0.959 ...
## $ FW_stridewidthcmmean : num 14.76 13.91 7.1 7.55 11.94 ...
## $ FW_stridewidthcmsd : num 4.97 3.75 4.08 3.19 3.08 ...
## $ FW_totaldsupportmean : num 27.3 30.5 20.4 26.9 24 ...
## $ FW_totaldsupportratiolr : num 0.985 1.003 0.992 0.984 1.046 ...
## $ FW_velocitycmsecmean : num 145 119 197 133 164 ...
## $ PWS_cadencestepsminmean : num 79.4 74.6 100.2 107.3 90.2 ...
## $ PWS_singlesupportmean : num 30.5 30.8 37.1 34.8 32.6 ...
## $ PWS_singlesupportratiolr : num 1.2 1.07 1.14 1.1 1.11 ...
## $ PWS_stridetimeseccv : num 24.5 21.4 23.5 15.5 36.1 ...
## $ PWS_stridetimesecmean : num 1.51 1.61 1.19 1.12 1.33 ...
## $ PWS_stridewidthcmmean : num 16.63 12.11 2.31 8.48 11.43 ...
## $ PWS_stridewidthcmsd : num 11.47 5.32 7.82 16.29 13.71 ...
## $ PWS_totaldsupportmean : num 35.4 35.2 36.4 30.4 30.1 ...
## $ PWS_totaldsupportratiolr : num 1.091 0.912 1.216 0.995 1.077 ...
## $ PWS_velocitycmsecmean : num 66.1 74.1 101.2 94.7 78 ...
## $ redcap_event_name : Factor w/ 4 levels "Brainwalk: Baseline visit (Arm 1: Baseline visit)",..: 1 2 1 1 1 2 2 3 1 2 ...
## $ demographic_diagnosis : Factor w/ 1 level "MS": 1 1 1 1 1 1 1 1 1 1 ...
## $ bingoEHR_Vitals_height.in. : num 66 NA 67.5 67 NA 68 65 66 63 63 ...
## $ bingoEHR_first_MS.DX : chr "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "PPMS (Primary-progressive Multiple Sclerosis)" ...
## $ edss_severity_num : num 2 2 2 2 2 1 2 2 2 2 ...
## $ edss_severity_cat : chr "moderate" "moderate" "moderate" "moderate" ...
## $ t25fw_group_num : num 1 2 1 1 1 1 1 1 1 2 ...
## $ t25fw_group_cat : chr "under_6" "6_to_8" "under_6" "under_6" ...
## $ race_ethnicity_clean : Factor w/ 5 levels "Asian","Black Or African American",..: 3 3 5 5 5 5 3 3 5 5 ...
## $ ms_dx_condensed : Factor w/ 3 levels "MS, Subtype Not Specified",..: 3 3 3 2 3 3 2 2 3 3 ...
# assign levels to categorical variables
table(zeno_pws_df$race_ethnicity_clean)
##
## Asian Black Or African American Hispanic or Latino
## 17 14 21
## Other/Unknown/Declined White Not Hispanic
## 18 154
zeno_pws_df$race_ethnicity_clean <- factor(zeno_pws_df$race_ethnicity_clean,
levels = c('White Not Hispanic',
'Asian',
'Black Or African American',
'Hispanic or Latino',
'Other/Unknown/Declined'),
ordered = FALSE)
print(levels(zeno_pws_df$race_ethnicity_clean))
## [1] "White Not Hispanic" "Asian"
## [3] "Black Or African American" "Hispanic or Latino"
## [5] "Other/Unknown/Declined"
table(zeno_pws_df$ms_dx_condensed)
##
## MS, Subtype Not Specified Progressive MS RRMS
## 3 40 181
zeno_pws_df$ms_dx_condensed <- factor(zeno_pws_df$ms_dx_condensed,
levels = c('RRMS',
'Progressive MS',
'MS, Subtype Not Specified'),
ordered = FALSE)
print(levels(zeno_pws_df$ms_dx_condensed))
## [1] "RRMS" "Progressive MS"
## [3] "MS, Subtype Not Specified"
table(zeno_pws_df$clean_sex)
##
## Female Male Non-Binary
## 168 54 2
zeno_pws_df$clean_sex <- factor(zeno_pws_df$clean_sex,
levels = c('Female',
'Male',
'Non-Binary'),
ordered = FALSE)
print(levels(zeno_pws_df$clean_sex))
## [1] "Female" "Male" "Non-Binary"
colSums(is.na(zeno_pws_df))
## X
## 0
## video_id_date_name_pose_zv
## 0
## id_date_pose_zv
## 0
## task_pose_zv
## 0
## frames_per_second_pose_zv
## 0
## total_video_duration_sec_pose_zv
## 0
## delta_pix_h_rel_median_pose_zv
## 16
## walking_segmets_n_pose_zv
## 40
## walking_segments_duration_mean_pose_zv
## 40
## walking_segments_duration_median_pose_zv
## 40
## stride_time_mean_sec_pose_zv
## 48
## stride_time_median_sec_pose_zv
## 48
## stride_time_std_pose_zv
## 53
## stride_time_cv_pose_zv
## 53
## stride_time_max_pose_zv
## 48
## stride_time_min_pose_zv
## 48
## mean_cadence_step_per_min_pose_zv
## 40
## stride_width_mean_cm_pose_zv
## 40
## stride_width_median_cm_pose_zv
## 40
## stride_width_std_pose_zv
## 42
## stride_width_cv_pose_zv
## 42
## stride_width_max_pose_zv
## 40
## stride_width_min_pose_zv
## 40
## foot1_gait_cycle_time_mean_pose_zv
## 163
## foot1_stance_time_mean_pose_zv
## 163
## foot1_stance_per_mean_pose_zv
## 163
## foot1_swing_time_mean_pose_zv
## 163
## foot1_swing_per_mean_pose_zv
## 163
## foot1_ini_double_support_time_mean_pose_zv
## 163
## foot1_term_double_support_time_mean_pose_zv
## 163
## foot1_tot_double_support_time_mean_pose_zv
## 163
## foot1_double_support_per_mean_pose_zv
## 163
## foot1_single_support_time_mean_pose_zv
## 163
## foot1_single_support_per_mean_pose_zv
## 163
## walk_segment_pose_zv
## 163
## foot1_pose_zv
## 0
## id_video
## 0
## visit_date_video
## 0
## bw_id
## 0
## trialdate
## 0
## visit_date
## 0
## demoEHR_DiseaseDuration
## 0
## clean_sex
## 0
## clean_race
## 0
## clean_ethnicity
## 0
## demoEHR_Age
## 0
## bingoEHR_DX_MS.DX
## 0
## bingoEHR_EDSS_measure_value
## 0
## msfcEHR_T25FW.SPEED.AVG
## 0
## FW_cadencestepsminmean
## 0
## FW_singlesupportmean
## 0
## FW_singlesupportratiolr
## 0
## FW_stridetimeseccv
## 0
## FW_stridetimesecmean
## 0
## FW_stridewidthcmmean
## 0
## FW_stridewidthcmsd
## 0
## FW_totaldsupportmean
## 0
## FW_totaldsupportratiolr
## 0
## FW_velocitycmsecmean
## 0
## PWS_cadencestepsminmean
## 0
## PWS_singlesupportmean
## 0
## PWS_singlesupportratiolr
## 0
## PWS_stridetimeseccv
## 0
## PWS_stridetimesecmean
## 0
## PWS_stridewidthcmmean
## 0
## PWS_stridewidthcmsd
## 0
## PWS_totaldsupportmean
## 0
## PWS_totaldsupportratiolr
## 0
## PWS_velocitycmsecmean
## 0
## redcap_event_name
## 0
## demographic_diagnosis
## 0
## bingoEHR_Vitals_height.in.
## 13
## bingoEHR_first_MS.DX
## 0
## edss_severity_num
## 0
## edss_severity_cat
## 0
## t25fw_group_num
## 0
## t25fw_group_cat
## 0
## race_ethnicity_clean
## 0
## ms_dx_condensed
## 0
table(zeno_pws_df$redcap_event_name)
##
## Brainwalk: Baseline visit (Arm 1: Baseline visit)
## 138
## Year 2 Visit (Arm 1: Baseline visit)
## 78
## Year 3 Visit (Arm 1: Baseline visit)
## 7
## Year 4 Visit (Arm 1: Baseline visit)
## 1
All videos included in analysis.
Each row = 1 video
zeno_fw_path <- file.path("C:/Users/mmccu/Box/MM_Personal/5_Projects/BoveLab/3_Data_and_Code/gait_bw_zeno_home_analysis",
metrics_version,
"000_merged_cleaned_data",
"zv_bw_merged_gait_vertical_FW_1_clean.csv")
zeno_fw_df <- read.csv(zeno_fw_path)
table(zeno_fw_df$task_pose)
##
## gait_vertical_FW_1
## 222
str(zeno_fw_df)
## 'data.frame': 222 obs. of 79 variables:
## $ X : int 0 1 3 4 5 6 8 9 11 12 ...
## $ video_id_date_name_pose_zv : chr "gait_vertical_FW_1_BW-0002_2022_09_12" "gait_vertical_FW_1_BW-0002_2023_09_12" "gait_vertical_FW_1_BW-0004_2022_09_19" "gait_vertical_FW_1_BW-0006_2022_09_26" ...
## $ id_date_pose_zv : chr "BW-0002\\2022_09_12" "BW-0002\\2023_09_12" "BW-0004\\2022_09_19" "BW-0006\\2022_09_26" ...
## $ task_pose_zv : chr "gait_vertical_FW_1" "gait_vertical_FW_1" "gait_vertical_FW_1" "gait_vertical_FW_1" ...
## $ frames_per_second_pose_zv : int 25 30 30 30 30 30 30 30 30 30 ...
## $ total_video_duration_sec_pose_zv : num 29 36.5 25.3 25 22.6 ...
## $ delta_pix_h_rel_median_pose_zv : num 0.28 0.25 0.36 0.27 0.43 0.23 0.44 0.35 0.44 0.29 ...
## $ walking_segmets_n_pose_zv : num NA 2 2 1 4 4 3 3 2 2 ...
## $ walking_segments_duration_mean_pose_zv : num NA 5.23 2.47 4.87 3.48 4.79 2.38 4.44 4.63 4.27 ...
## $ walking_segments_duration_median_pose_zv : num NA 5.23 2.47 4.87 3.47 4.97 2.1 4.4 4.63 4.27 ...
## $ stride_time_mean_sec_pose_zv : num NA 1.007 1.433 0.957 1.027 ...
## $ stride_time_median_sec_pose_zv : num NA 1.067 1.333 0.967 0.933 ...
## $ stride_time_std_pose_zv : num NA 0.266 0.233 0.037 0.189 0.126 0.052 0.101 0.066 0.055 ...
## $ stride_time_cv_pose_zv : num NA 26.44 16.28 3.88 18.38 ...
## $ stride_time_max_pose_zv : num NA 1.27 1.7 1 1.5 ...
## $ stride_time_min_pose_zv : num NA 0.433 1.267 0.9 0.7 ...
## $ mean_cadence_step_per_min_pose_zv : num NA 120 110 123 117 ...
## $ stride_width_mean_cm_pose_zv : num NA 13.75 8.97 15.99 10.74 ...
## $ stride_width_median_cm_pose_zv : num NA 14.28 8.87 15.02 11.1 ...
## $ stride_width_std_pose_zv : num NA 5.39 5.71 4.27 4.49 ...
## $ stride_width_cv_pose_zv : num NA 39.2 63.7 26.7 41.8 ...
## $ stride_width_max_pose_zv : num NA 22.6 17.4 23.1 17.2 ...
## $ stride_width_min_pose_zv : num NA 1.69 2.53 11.27 2.33 ...
## $ foot1_gait_cycle_time_mean_pose_zv : num NA NA 1 NA 0.8 0.867 NA NA NA NA ...
## $ foot1_stance_time_mean_pose_zv : num NA NA 0.533 NA 0.5 0.567 NA NA NA NA ...
## $ foot1_stance_per_mean_pose_zv : num NA NA 53.3 NA 62.5 ...
## $ foot1_swing_time_mean_pose_zv : num NA NA 0.467 NA 0.3 0.3 NA NA NA NA ...
## $ foot1_swing_per_mean_pose_zv : num NA NA 46.7 NA 37.5 ...
## $ foot1_ini_double_support_time_mean_pose_zv : num NA NA 0.1 NA 0.033 0.067 NA NA NA NA ...
## $ foot1_term_double_support_time_mean_pose_zv: num NA NA 0.1 NA 0.033 0.167 NA NA NA NA ...
## $ foot1_tot_double_support_time_mean_pose_zv : num NA NA 0.2 NA 0.067 0.233 NA NA NA NA ...
## $ foot1_double_support_per_mean_pose_zv : num NA NA 20 NA 8.33 ...
## $ foot1_single_support_time_mean_pose_zv : num NA NA 0.333 NA 0.433 0.333 NA NA NA NA ...
## $ foot1_single_support_per_mean_pose_zv : num NA NA 33.3 NA 54.2 ...
## $ walk_segment_pose_zv : num NA NA 0 NA 0 2 NA NA NA NA ...
## $ foot1_pose_zv : chr "" "" "left" "" ...
## $ id_video : chr "BW-0002" "BW-0002" "BW-0004" "BW-0006" ...
## $ visit_date_video : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ bw_id : chr "BW-0002" "BW-0002" "BW-0004" "BW-0006" ...
## $ trialdate : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ visit_date : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ demoEHR_DiseaseDuration : num 0 1 17 17 7 8 25 26 30 31 ...
## $ clean_sex : chr "Male" "Male" "Female" "Female" ...
## $ clean_race : chr "Other" "Other" "White" "White" ...
## $ clean_ethnicity : chr "Hispanic Or Latino" "Hispanic Or Latino" "Not Hispanic Or Latino" "Not Hispanic Or Latino" ...
## $ demoEHR_Age : num 37 37 46 65 53 53 60 60 71 71 ...
## $ bingoEHR_DX_MS.DX : chr "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "PPMS (Primary-progressive Multiple Sclerosis)" ...
## $ bingoEHR_EDSS_measure_value : num 3.5 3 3 3 3 2 3 3 3.5 3.5 ...
## $ msfcEHR_T25FW.SPEED.AVG : num 5 6.1 4.3 4.6 4.6 4.9 3.7 4.4 5.2 6.1 ...
## $ FW_cadencestepsminmean : num 113 103 134 120 124 ...
## $ FW_singlesupportmean : num 36.8 34.7 39.8 36.5 38.1 ...
## $ FW_singlesupportratiolr : num 1.09 1.11 1.02 1.07 1.01 ...
## $ FW_stridetimeseccv : num 4.01 5.92 3.1 3.12 3.77 ...
## $ FW_stridetimesecmean : num 1.061 1.158 0.891 0.99 0.959 ...
## $ FW_stridewidthcmmean : num 14.76 13.91 7.1 7.55 11.94 ...
## $ FW_stridewidthcmsd : num 4.97 3.75 4.08 3.19 3.08 ...
## $ FW_totaldsupportmean : num 27.3 30.5 20.4 26.9 24 ...
## $ FW_totaldsupportratiolr : num 0.985 1.003 0.992 0.984 1.046 ...
## $ FW_velocitycmsecmean : num 145 119 197 133 164 ...
## $ PWS_cadencestepsminmean : num 79.4 74.6 100.2 107.3 90.2 ...
## $ PWS_singlesupportmean : num 30.5 30.8 37.1 34.8 32.6 ...
## $ PWS_singlesupportratiolr : num 1.2 1.07 1.14 1.1 1.11 ...
## $ PWS_stridetimeseccv : num 24.5 21.4 23.5 15.5 36.1 ...
## $ PWS_stridetimesecmean : num 1.51 1.61 1.19 1.12 1.33 ...
## $ PWS_stridewidthcmmean : num 16.63 12.11 2.31 8.48 11.43 ...
## $ PWS_stridewidthcmsd : num 11.47 5.32 7.82 16.29 13.71 ...
## $ PWS_totaldsupportmean : num 35.4 35.2 36.4 30.4 30.1 ...
## $ PWS_totaldsupportratiolr : num 1.091 0.912 1.216 0.995 1.077 ...
## $ PWS_velocitycmsecmean : num 66.1 74.1 101.2 94.7 78 ...
## $ redcap_event_name : chr "Brainwalk: Baseline visit (Arm 1: Baseline visit)" "Year 2 Visit (Arm 1: Baseline visit)" "Brainwalk: Baseline visit (Arm 1: Baseline visit)" "Brainwalk: Baseline visit (Arm 1: Baseline visit)" ...
## $ demographic_diagnosis : chr "MS" "MS" "MS" "MS" ...
## $ bingoEHR_Vitals_height.in. : num 66 NA 67.5 67 NA 68 65 66 63 63 ...
## $ bingoEHR_first_MS.DX : chr "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "PPMS (Primary-progressive Multiple Sclerosis)" ...
## $ edss_severity_num : num 2 2 2 2 2 1 2 2 2 2 ...
## $ edss_severity_cat : chr "moderate" "moderate" "moderate" "moderate" ...
## $ t25fw_group_num : num 1 2 1 1 1 1 1 1 1 2 ...
## $ t25fw_group_cat : chr "under_6" "6_to_8" "under_6" "under_6" ...
## $ race_ethnicity_clean : chr "Hispanic or Latino" "Hispanic or Latino" "White Not Hispanic" "White Not Hispanic" ...
## $ ms_dx_condensed : chr "RRMS" "RRMS" "RRMS" "Progressive MS" ...
zeno_fw_df <- zeno_fw_df %>%
mutate_at(c("video_id_date_name_pose_zv", "id_date_pose_zv", "task_pose_zv",
"id_video", "bw_id", "clean_sex", "bingoEHR_DX_MS.DX",
"demographic_diagnosis", "race_ethnicity_clean",
"race_ethnicity_clean", "ms_dx_condensed",
"redcap_event_name"),
as.factor)
str(zeno_fw_df)
## 'data.frame': 222 obs. of 79 variables:
## $ X : int 0 1 3 4 5 6 8 9 11 12 ...
## $ video_id_date_name_pose_zv : Factor w/ 222 levels "gait_vertical_FW_1_BW-0002_2022_09_12",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ id_date_pose_zv : Factor w/ 222 levels "BW-0002\\2022_09_12",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ task_pose_zv : Factor w/ 1 level "gait_vertical_FW_1": 1 1 1 1 1 1 1 1 1 1 ...
## $ frames_per_second_pose_zv : int 25 30 30 30 30 30 30 30 30 30 ...
## $ total_video_duration_sec_pose_zv : num 29 36.5 25.3 25 22.6 ...
## $ delta_pix_h_rel_median_pose_zv : num 0.28 0.25 0.36 0.27 0.43 0.23 0.44 0.35 0.44 0.29 ...
## $ walking_segmets_n_pose_zv : num NA 2 2 1 4 4 3 3 2 2 ...
## $ walking_segments_duration_mean_pose_zv : num NA 5.23 2.47 4.87 3.48 4.79 2.38 4.44 4.63 4.27 ...
## $ walking_segments_duration_median_pose_zv : num NA 5.23 2.47 4.87 3.47 4.97 2.1 4.4 4.63 4.27 ...
## $ stride_time_mean_sec_pose_zv : num NA 1.007 1.433 0.957 1.027 ...
## $ stride_time_median_sec_pose_zv : num NA 1.067 1.333 0.967 0.933 ...
## $ stride_time_std_pose_zv : num NA 0.266 0.233 0.037 0.189 0.126 0.052 0.101 0.066 0.055 ...
## $ stride_time_cv_pose_zv : num NA 26.44 16.28 3.88 18.38 ...
## $ stride_time_max_pose_zv : num NA 1.27 1.7 1 1.5 ...
## $ stride_time_min_pose_zv : num NA 0.433 1.267 0.9 0.7 ...
## $ mean_cadence_step_per_min_pose_zv : num NA 120 110 123 117 ...
## $ stride_width_mean_cm_pose_zv : num NA 13.75 8.97 15.99 10.74 ...
## $ stride_width_median_cm_pose_zv : num NA 14.28 8.87 15.02 11.1 ...
## $ stride_width_std_pose_zv : num NA 5.39 5.71 4.27 4.49 ...
## $ stride_width_cv_pose_zv : num NA 39.2 63.7 26.7 41.8 ...
## $ stride_width_max_pose_zv : num NA 22.6 17.4 23.1 17.2 ...
## $ stride_width_min_pose_zv : num NA 1.69 2.53 11.27 2.33 ...
## $ foot1_gait_cycle_time_mean_pose_zv : num NA NA 1 NA 0.8 0.867 NA NA NA NA ...
## $ foot1_stance_time_mean_pose_zv : num NA NA 0.533 NA 0.5 0.567 NA NA NA NA ...
## $ foot1_stance_per_mean_pose_zv : num NA NA 53.3 NA 62.5 ...
## $ foot1_swing_time_mean_pose_zv : num NA NA 0.467 NA 0.3 0.3 NA NA NA NA ...
## $ foot1_swing_per_mean_pose_zv : num NA NA 46.7 NA 37.5 ...
## $ foot1_ini_double_support_time_mean_pose_zv : num NA NA 0.1 NA 0.033 0.067 NA NA NA NA ...
## $ foot1_term_double_support_time_mean_pose_zv: num NA NA 0.1 NA 0.033 0.167 NA NA NA NA ...
## $ foot1_tot_double_support_time_mean_pose_zv : num NA NA 0.2 NA 0.067 0.233 NA NA NA NA ...
## $ foot1_double_support_per_mean_pose_zv : num NA NA 20 NA 8.33 ...
## $ foot1_single_support_time_mean_pose_zv : num NA NA 0.333 NA 0.433 0.333 NA NA NA NA ...
## $ foot1_single_support_per_mean_pose_zv : num NA NA 33.3 NA 54.2 ...
## $ walk_segment_pose_zv : num NA NA 0 NA 0 2 NA NA NA NA ...
## $ foot1_pose_zv : chr "" "" "left" "" ...
## $ id_video : Factor w/ 154 levels "BW-0002","BW-0004",..: 1 1 2 3 4 4 5 5 6 6 ...
## $ visit_date_video : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ bw_id : Factor w/ 154 levels "BW-0002","BW-0004",..: 1 1 2 3 4 4 5 5 6 6 ...
## $ trialdate : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ visit_date : chr "2022-09-12" "2023-09-12" "2022-09-19" "2022-09-26" ...
## $ demoEHR_DiseaseDuration : num 0 1 17 17 7 8 25 26 30 31 ...
## $ clean_sex : Factor w/ 3 levels "Female","Male",..: 2 2 1 1 1 1 2 2 1 1 ...
## $ clean_race : chr "Other" "Other" "White" "White" ...
## $ clean_ethnicity : chr "Hispanic Or Latino" "Hispanic Or Latino" "Not Hispanic Or Latino" "Not Hispanic Or Latino" ...
## $ demoEHR_Age : num 37 37 46 65 53 53 60 60 71 71 ...
## $ bingoEHR_DX_MS.DX : Factor w/ 5 levels "MS, Subtype Not Specified",..: 4 4 4 2 4 4 5 5 4 4 ...
## $ bingoEHR_EDSS_measure_value : num 3.5 3 3 3 3 2 3 3 3.5 3.5 ...
## $ msfcEHR_T25FW.SPEED.AVG : num 5 6.1 4.3 4.6 4.6 4.9 3.7 4.4 5.2 6.1 ...
## $ FW_cadencestepsminmean : num 113 103 134 120 124 ...
## $ FW_singlesupportmean : num 36.8 34.7 39.8 36.5 38.1 ...
## $ FW_singlesupportratiolr : num 1.09 1.11 1.02 1.07 1.01 ...
## $ FW_stridetimeseccv : num 4.01 5.92 3.1 3.12 3.77 ...
## $ FW_stridetimesecmean : num 1.061 1.158 0.891 0.99 0.959 ...
## $ FW_stridewidthcmmean : num 14.76 13.91 7.1 7.55 11.94 ...
## $ FW_stridewidthcmsd : num 4.97 3.75 4.08 3.19 3.08 ...
## $ FW_totaldsupportmean : num 27.3 30.5 20.4 26.9 24 ...
## $ FW_totaldsupportratiolr : num 0.985 1.003 0.992 0.984 1.046 ...
## $ FW_velocitycmsecmean : num 145 119 197 133 164 ...
## $ PWS_cadencestepsminmean : num 79.4 74.6 100.2 107.3 90.2 ...
## $ PWS_singlesupportmean : num 30.5 30.8 37.1 34.8 32.6 ...
## $ PWS_singlesupportratiolr : num 1.2 1.07 1.14 1.1 1.11 ...
## $ PWS_stridetimeseccv : num 24.5 21.4 23.5 15.5 36.1 ...
## $ PWS_stridetimesecmean : num 1.51 1.61 1.19 1.12 1.33 ...
## $ PWS_stridewidthcmmean : num 16.63 12.11 2.31 8.48 11.43 ...
## $ PWS_stridewidthcmsd : num 11.47 5.32 7.82 16.29 13.71 ...
## $ PWS_totaldsupportmean : num 35.4 35.2 36.4 30.4 30.1 ...
## $ PWS_totaldsupportratiolr : num 1.091 0.912 1.216 0.995 1.077 ...
## $ PWS_velocitycmsecmean : num 66.1 74.1 101.2 94.7 78 ...
## $ redcap_event_name : Factor w/ 4 levels "Brainwalk: Baseline visit (Arm 1: Baseline visit)",..: 1 2 1 1 1 2 2 3 1 2 ...
## $ demographic_diagnosis : Factor w/ 1 level "MS": 1 1 1 1 1 1 1 1 1 1 ...
## $ bingoEHR_Vitals_height.in. : num 66 NA 67.5 67 NA 68 65 66 63 63 ...
## $ bingoEHR_first_MS.DX : chr "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "PPMS (Primary-progressive Multiple Sclerosis)" ...
## $ edss_severity_num : num 2 2 2 2 2 1 2 2 2 2 ...
## $ edss_severity_cat : chr "moderate" "moderate" "moderate" "moderate" ...
## $ t25fw_group_num : num 1 2 1 1 1 1 1 1 1 2 ...
## $ t25fw_group_cat : chr "under_6" "6_to_8" "under_6" "under_6" ...
## $ race_ethnicity_clean : Factor w/ 5 levels "Asian","Black Or African American",..: 3 3 5 5 5 5 3 3 5 5 ...
## $ ms_dx_condensed : Factor w/ 3 levels "MS, Subtype Not Specified",..: 3 3 3 2 3 3 2 2 3 3 ...
# assign levels to categorical variables
table(zeno_fw_df$race_ethnicity_clean)
##
## Asian Black Or African American Hispanic or Latino
## 17 14 20
## Other/Unknown/Declined White Not Hispanic
## 18 153
zeno_fw_df$race_ethnicity_clean <- factor(zeno_fw_df$race_ethnicity_clean,
levels = c('White Not Hispanic',
'Asian',
'Black Or African American',
'Hispanic or Latino',
'Other/Unknown/Declined'),
ordered = FALSE)
print(levels(zeno_fw_df$race_ethnicity_clean))
## [1] "White Not Hispanic" "Asian"
## [3] "Black Or African American" "Hispanic or Latino"
## [5] "Other/Unknown/Declined"
table(zeno_fw_df$ms_dx_condensed)
##
## MS, Subtype Not Specified Progressive MS RRMS
## 2 39 181
zeno_fw_df$ms_dx_condensed <- factor(zeno_fw_df$ms_dx_condensed,
levels = c('RRMS',
'Progressive MS',
'MS, Subtype Not Specified'),
ordered = FALSE)
print(levels(zeno_fw_df$ms_dx_condensed))
## [1] "RRMS" "Progressive MS"
## [3] "MS, Subtype Not Specified"
table(zeno_fw_df$clean_sex)
##
## Female Male Non-Binary
## 167 53 2
zeno_fw_df$clean_sex <- factor(zeno_fw_df$clean_sex,
levels = c('Female',
'Male',
'Non-Binary'),
ordered = FALSE)
print(levels(zeno_fw_df$clean_sex))
## [1] "Female" "Male" "Non-Binary"
colSums(is.na(zeno_fw_df))
## X
## 0
## video_id_date_name_pose_zv
## 0
## id_date_pose_zv
## 0
## task_pose_zv
## 0
## frames_per_second_pose_zv
## 0
## total_video_duration_sec_pose_zv
## 0
## delta_pix_h_rel_median_pose_zv
## 3
## walking_segmets_n_pose_zv
## 46
## walking_segments_duration_mean_pose_zv
## 46
## walking_segments_duration_median_pose_zv
## 46
## stride_time_mean_sec_pose_zv
## 53
## stride_time_median_sec_pose_zv
## 53
## stride_time_std_pose_zv
## 54
## stride_time_cv_pose_zv
## 54
## stride_time_max_pose_zv
## 53
## stride_time_min_pose_zv
## 53
## mean_cadence_step_per_min_pose_zv
## 46
## stride_width_mean_cm_pose_zv
## 47
## stride_width_median_cm_pose_zv
## 47
## stride_width_std_pose_zv
## 49
## stride_width_cv_pose_zv
## 49
## stride_width_max_pose_zv
## 47
## stride_width_min_pose_zv
## 47
## foot1_gait_cycle_time_mean_pose_zv
## 188
## foot1_stance_time_mean_pose_zv
## 188
## foot1_stance_per_mean_pose_zv
## 188
## foot1_swing_time_mean_pose_zv
## 188
## foot1_swing_per_mean_pose_zv
## 188
## foot1_ini_double_support_time_mean_pose_zv
## 188
## foot1_term_double_support_time_mean_pose_zv
## 188
## foot1_tot_double_support_time_mean_pose_zv
## 188
## foot1_double_support_per_mean_pose_zv
## 188
## foot1_single_support_time_mean_pose_zv
## 188
## foot1_single_support_per_mean_pose_zv
## 188
## walk_segment_pose_zv
## 188
## foot1_pose_zv
## 0
## id_video
## 0
## visit_date_video
## 0
## bw_id
## 0
## trialdate
## 0
## visit_date
## 0
## demoEHR_DiseaseDuration
## 0
## clean_sex
## 0
## clean_race
## 0
## clean_ethnicity
## 0
## demoEHR_Age
## 0
## bingoEHR_DX_MS.DX
## 0
## bingoEHR_EDSS_measure_value
## 0
## msfcEHR_T25FW.SPEED.AVG
## 0
## FW_cadencestepsminmean
## 0
## FW_singlesupportmean
## 0
## FW_singlesupportratiolr
## 0
## FW_stridetimeseccv
## 0
## FW_stridetimesecmean
## 0
## FW_stridewidthcmmean
## 0
## FW_stridewidthcmsd
## 0
## FW_totaldsupportmean
## 0
## FW_totaldsupportratiolr
## 0
## FW_velocitycmsecmean
## 0
## PWS_cadencestepsminmean
## 0
## PWS_singlesupportmean
## 0
## PWS_singlesupportratiolr
## 0
## PWS_stridetimeseccv
## 0
## PWS_stridetimesecmean
## 0
## PWS_stridewidthcmmean
## 0
## PWS_stridewidthcmsd
## 0
## PWS_totaldsupportmean
## 0
## PWS_totaldsupportratiolr
## 0
## PWS_velocitycmsecmean
## 0
## redcap_event_name
## 0
## demographic_diagnosis
## 0
## bingoEHR_Vitals_height.in.
## 13
## bingoEHR_first_MS.DX
## 0
## edss_severity_num
## 0
## edss_severity_cat
## 0
## t25fw_group_num
## 0
## t25fw_group_cat
## 0
## race_ethnicity_clean
## 0
## ms_dx_condensed
## 0
table(zeno_fw_df$redcap_event_name)
##
## Brainwalk: Baseline visit (Arm 1: Baseline visit)
## 139
## Year 2 Visit (Arm 1: Baseline visit)
## 75
## Year 3 Visit (Arm 1: Baseline visit)
## 7
## Year 4 Visit (Arm 1: Baseline visit)
## 1
home_path <- file.path("C:/Users/mmccu/Box/MM_Personal/5_Projects/BoveLab/3_Data_and_Code/gait_bw_zeno_home_analysis",
metrics_version,
"000_merged_cleaned_data",
"hv_bw_merged_clean.csv")
home_df <- read.csv(home_path)
nrow(home_df)
## [1] 65
table(home_df$demographic_diagnosis)
##
## MS
## 65
table(home_df$task_pose_hv)
##
## gait_vertical_left gait_vertical_right
## 32 33
str(home_df)
## 'data.frame': 65 obs. of 80 variables:
## $ X : int 0 1 2 3 4 5 6 8 10 11 ...
## $ video_id_date_name_pose_hv : chr "gait_vertical_left_BW-0018_10-24-23" "gait_vertical_right_BW-0018_10-24-23" "gait_vertical_left_BW-0023_05-05-23" "gait_vertical_right_BW-0023_05-05-23" ...
## $ id_date_pose_hv : chr "BW-0018\\10-24-23" "BW-0018\\10-24-23" "BW-0023\\05-05-23" "BW-0023\\05-05-23" ...
## $ task_pose_hv : chr "gait_vertical_left" "gait_vertical_right" "gait_vertical_left" "gait_vertical_right" ...
## $ frames_per_second_pose_hv : int 30 30 30 30 30 30 30 30 30 30 ...
## $ total_video_duration_sec_pose_hv : num 26.8 24.4 36 38.5 36.1 ...
## $ delta_pix_h_rel_median_pose_hv : num 0.22 0.31 0.43 0.39 0.3 0.39 0.03 0.08 0.22 0.24 ...
## $ walking_segmets_n_pose_hv : num 1 1 4 5 3 2 NA NA 5 5 ...
## $ walking_segments_duration_mean_pose_hv : num 3.17 2.4 4.42 4.78 4.19 5.07 NA NA 4.47 3.77 ...
## $ walking_segments_duration_median_pose_hv : num 3.17 2.4 4.33 4.63 3.83 5.07 NA NA 4.3 3.7 ...
## $ stride_time_mean_sec_pose_hv : num 1.008 NA 1.027 1.07 0.998 ...
## $ stride_time_median_sec_pose_hv : num 1.05 NA 1.033 1.033 0.983 ...
## $ stride_time_std_pose_hv : num 0.171 NA 0.066 0.098 0.087 0.076 NA NA 0.229 0.078 ...
## $ stride_time_cv_pose_hv : num 16.94 NA 6.46 9.11 8.74 ...
## $ stride_time_max_pose_hv : num 1.17 NA 1.17 1.3 1.1 ...
## $ stride_time_min_pose_hv : num 0.767 NA 0.833 0.933 0.867 ...
## $ mean_cadence_step_per_min_pose_hv : num 133 75 113 106 111 ...
## $ stride_width_mean_cm_pose_hv : num 12.81 8.21 10.59 10.62 9.89 ...
## $ stride_width_median_cm_pose_hv : num 13.34 8.21 10.69 10.86 9.13 ...
## $ stride_width_std_pose_hv : num 3.54 10.46 3.52 3.6 3.19 ...
## $ stride_width_cv_pose_hv : num 27.6 127.4 33.3 33.9 32.3 ...
## $ stride_width_max_pose_hv : num 17.4 15.6 19.6 17.9 14.8 ...
## $ stride_width_min_pose_hv : num 7.921 0.813 4.529 0.624 4.146 ...
## $ foot1_gait_cycle_time_mean_pose_hv : num 1.3 NA NA NA NA ...
## $ foot1_stance_time_mean_pose_hv : num 0.9 NA NA NA NA ...
## $ foot1_stance_per_mean_pose_hv : num 69.2 NA NA NA NA ...
## $ foot1_swing_time_mean_pose_hv : num 0.4 NA NA NA NA 0.433 NA NA 0.333 0.433 ...
## $ foot1_swing_per_mean_pose_hv : num 30.8 NA NA NA NA ...
## $ foot1_ini_double_support_time_mean_pose_hv : num 0.4 NA NA NA NA 0.433 NA NA 0.5 0.333 ...
## $ foot1_term_double_support_time_mean_pose_hv: num 0.2 NA NA NA NA 0.033 NA NA 0.033 0.433 ...
## $ foot1_tot_double_support_time_mean_pose_hv : num 0.6 NA NA NA NA 0.467 NA NA 0.533 0.767 ...
## $ foot1_double_support_per_mean_pose_hv : num 46.2 NA NA NA NA ...
## $ foot1_single_support_time_mean_pose_hv : num 0.3 NA NA NA NA 0.467 NA NA 0.6 0.333 ...
## $ foot1_single_support_per_mean_pose_hv : num 23.1 NA NA NA NA ...
## $ walk_segment_pose_hv : num 0 NA NA NA NA 1 NA NA 1 1 ...
## $ foot1_pose_hv : chr "right" "" "" "" ...
## $ id_video : chr "BW-0018" "BW-0018" "BW-0023" "BW-0023" ...
## $ visit_date_video : chr "2023-10-24" "2023-10-24" "2023-05-05" "2023-05-05" ...
## $ bw_id : chr "BW-0018" "BW-0018" "BW-0023" "BW-0023" ...
## $ trialdate : chr "2023-10-24" "2023-10-24" "2023-04-26" "2023-04-26" ...
## $ visit_date : chr "2023-10-24" "2023-10-24" "2023-04-26" "2023-04-26" ...
## $ demoEHR_DiseaseDuration : num 4 4 21 21 22 22 14 14 7 7 ...
## $ clean_sex : chr "Male" "Male" "Female" "Female" ...
## $ clean_race : chr "White" "White" "Other" "Other" ...
## $ clean_ethnicity : chr "Not Hispanic Or Latino" "Not Hispanic Or Latino" "Not Hispanic Or Latino" "Not Hispanic Or Latino" ...
## $ demoEHR_Age : num 57 57 40 40 40 40 35 35 64 64 ...
## $ bingoEHR_DX_MS.DX : chr "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" ...
## $ bingoEHR_EDSS_measure_value : num 3 3 3.5 3.5 2.5 2.5 4.5 4.5 6.5 6.5 ...
## $ msfcEHR_T25FW.SPEED.AVG : num 3.6 3.6 3.4 3.4 4.4 4.4 4.4 4.4 6.6 6.6 ...
## $ FW_cadencestepsminmean : num 121 121 139 139 151 ...
## $ FW_singlesupportmean : num 32.5 32.5 38.9 38.9 39.9 ...
## $ FW_singlesupportratiolr : num 0.816 0.816 1.017 1.017 0.992 ...
## $ FW_stridetimeseccv : num 36.37 36.37 5.61 5.61 14.06 ...
## $ FW_stridetimesecmean : num 0.999 0.999 0.858 0.858 0.806 ...
## $ FW_stridewidthcmmean : num 5.55 5.55 6.85 6.85 9.31 ...
## $ FW_stridewidthcmsd : num 22.62 22.62 2.3 2.3 3.12 ...
## $ FW_totaldsupportmean : num 25.6 25.6 21.8 21.8 19.5 ...
## $ FW_totaldsupportratiolr : num 0.845 0.845 0.983 0.983 0.995 ...
## $ FW_velocitycmsecmean : num 123 123 190 190 205 ...
## $ PWS_cadencestepsminmean : num 116 116 112 112 127 ...
## $ PWS_singlesupportmean : num 34.8 34.8 35.8 35.8 36.9 ...
## $ PWS_singlesupportratiolr : num 0.952 0.952 1.038 1.038 1.02 ...
## $ PWS_stridetimeseccv : num 3.49 3.49 6.24 6.24 5.56 ...
## $ PWS_stridetimesecmean : num 1.028 1.028 1.065 1.065 0.945 ...
## $ PWS_stridewidthcmmean : num 8.19 8.19 8.33 8.33 8.69 ...
## $ PWS_stridewidthcmsd : num 3.72 3.72 2.38 2.38 1.95 ...
## $ PWS_totaldsupportmean : num 30.3 30.3 28.5 28.5 26.1 ...
## $ PWS_totaldsupportratiolr : num 1.01 1.01 0.98 0.98 1 ...
## $ PWS_velocitycmsecmean : num 137 137 116 116 140 ...
## $ redcap_event_name : chr "Year 2 Visit (Arm 1: Baseline visit)" "Year 2 Visit (Arm 1: Baseline visit)" "Year 2 Visit (Arm 1: Baseline visit)" "Year 2 Visit (Arm 1: Baseline visit)" ...
## $ demographic_diagnosis : chr "MS" "MS" "MS" "MS" ...
## $ bingoEHR_Vitals_height.in. : num 67 67 66 66 66 66 66 66 67 67 ...
## $ bingoEHR_first_MS.DX : chr "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" ...
## $ edss_severity_num : num 2 2 2 2 2 2 3 3 3 3 ...
## $ edss_severity_cat : chr "moderate" "moderate" "moderate" "moderate" ...
## $ t25fw_group_num : num 1 1 1 1 1 1 1 1 2 2 ...
## $ t25fw_group_cat : chr "under_6" "under_6" "under_6" "under_6" ...
## $ race_ethnicity_clean : chr "White Not Hispanic" "White Not Hispanic" "Other/Unknown/Declined" "Other/Unknown/Declined" ...
## $ ms_dx_condensed : chr "RRMS" "RRMS" "RRMS" "RRMS" ...
## $ bw_hv_abs_date_diff : chr "0 days" "0 days" "9 days" "9 days" ...
home_df <- home_df %>%
mutate_at(c("video_id_date_name_pose_hv", "id_date_pose_hv", "task_pose_hv",
"id_video", "bw_id", "clean_sex", "bingoEHR_DX_MS.DX",
"demographic_diagnosis", "race_ethnicity_clean",
"race_ethnicity_clean", "ms_dx_condensed",
"redcap_event_name"),
as.factor)
str(home_df)
## 'data.frame': 65 obs. of 80 variables:
## $ X : int 0 1 2 3 4 5 6 8 10 11 ...
## $ video_id_date_name_pose_hv : Factor w/ 65 levels "gait_vertical_left_BW-0018_10-24-23",..: 1 33 2 34 3 35 4 36 5 37 ...
## $ id_date_pose_hv : Factor w/ 35 levels "BW-0018\\10-24-23",..: 1 1 2 2 3 3 4 4 5 5 ...
## $ task_pose_hv : Factor w/ 2 levels "gait_vertical_left",..: 1 2 1 2 1 2 1 2 1 2 ...
## $ frames_per_second_pose_hv : int 30 30 30 30 30 30 30 30 30 30 ...
## $ total_video_duration_sec_pose_hv : num 26.8 24.4 36 38.5 36.1 ...
## $ delta_pix_h_rel_median_pose_hv : num 0.22 0.31 0.43 0.39 0.3 0.39 0.03 0.08 0.22 0.24 ...
## $ walking_segmets_n_pose_hv : num 1 1 4 5 3 2 NA NA 5 5 ...
## $ walking_segments_duration_mean_pose_hv : num 3.17 2.4 4.42 4.78 4.19 5.07 NA NA 4.47 3.77 ...
## $ walking_segments_duration_median_pose_hv : num 3.17 2.4 4.33 4.63 3.83 5.07 NA NA 4.3 3.7 ...
## $ stride_time_mean_sec_pose_hv : num 1.008 NA 1.027 1.07 0.998 ...
## $ stride_time_median_sec_pose_hv : num 1.05 NA 1.033 1.033 0.983 ...
## $ stride_time_std_pose_hv : num 0.171 NA 0.066 0.098 0.087 0.076 NA NA 0.229 0.078 ...
## $ stride_time_cv_pose_hv : num 16.94 NA 6.46 9.11 8.74 ...
## $ stride_time_max_pose_hv : num 1.17 NA 1.17 1.3 1.1 ...
## $ stride_time_min_pose_hv : num 0.767 NA 0.833 0.933 0.867 ...
## $ mean_cadence_step_per_min_pose_hv : num 133 75 113 106 111 ...
## $ stride_width_mean_cm_pose_hv : num 12.81 8.21 10.59 10.62 9.89 ...
## $ stride_width_median_cm_pose_hv : num 13.34 8.21 10.69 10.86 9.13 ...
## $ stride_width_std_pose_hv : num 3.54 10.46 3.52 3.6 3.19 ...
## $ stride_width_cv_pose_hv : num 27.6 127.4 33.3 33.9 32.3 ...
## $ stride_width_max_pose_hv : num 17.4 15.6 19.6 17.9 14.8 ...
## $ stride_width_min_pose_hv : num 7.921 0.813 4.529 0.624 4.146 ...
## $ foot1_gait_cycle_time_mean_pose_hv : num 1.3 NA NA NA NA ...
## $ foot1_stance_time_mean_pose_hv : num 0.9 NA NA NA NA ...
## $ foot1_stance_per_mean_pose_hv : num 69.2 NA NA NA NA ...
## $ foot1_swing_time_mean_pose_hv : num 0.4 NA NA NA NA 0.433 NA NA 0.333 0.433 ...
## $ foot1_swing_per_mean_pose_hv : num 30.8 NA NA NA NA ...
## $ foot1_ini_double_support_time_mean_pose_hv : num 0.4 NA NA NA NA 0.433 NA NA 0.5 0.333 ...
## $ foot1_term_double_support_time_mean_pose_hv: num 0.2 NA NA NA NA 0.033 NA NA 0.033 0.433 ...
## $ foot1_tot_double_support_time_mean_pose_hv : num 0.6 NA NA NA NA 0.467 NA NA 0.533 0.767 ...
## $ foot1_double_support_per_mean_pose_hv : num 46.2 NA NA NA NA ...
## $ foot1_single_support_time_mean_pose_hv : num 0.3 NA NA NA NA 0.467 NA NA 0.6 0.333 ...
## $ foot1_single_support_per_mean_pose_hv : num 23.1 NA NA NA NA ...
## $ walk_segment_pose_hv : num 0 NA NA NA NA 1 NA NA 1 1 ...
## $ foot1_pose_hv : chr "right" "" "" "" ...
## $ id_video : Factor w/ 31 levels "BW-0018","BW-0023",..: 1 1 2 2 2 2 3 3 4 4 ...
## $ visit_date_video : chr "2023-10-24" "2023-10-24" "2023-05-05" "2023-05-05" ...
## $ bw_id : Factor w/ 31 levels "BW-0018","BW-0023",..: 1 1 2 2 2 2 3 3 4 4 ...
## $ trialdate : chr "2023-10-24" "2023-10-24" "2023-04-26" "2023-04-26" ...
## $ visit_date : chr "2023-10-24" "2023-10-24" "2023-04-26" "2023-04-26" ...
## $ demoEHR_DiseaseDuration : num 4 4 21 21 22 22 14 14 7 7 ...
## $ clean_sex : Factor w/ 3 levels "Female","Male",..: 2 2 1 1 1 1 1 1 1 1 ...
## $ clean_race : chr "White" "White" "Other" "Other" ...
## $ clean_ethnicity : chr "Not Hispanic Or Latino" "Not Hispanic Or Latino" "Not Hispanic Or Latino" "Not Hispanic Or Latino" ...
## $ demoEHR_Age : num 57 57 40 40 40 40 35 35 64 64 ...
## $ bingoEHR_DX_MS.DX : Factor w/ 4 levels "MS, Subtype Not Specified",..: 3 3 3 3 3 3 3 3 2 2 ...
## $ bingoEHR_EDSS_measure_value : num 3 3 3.5 3.5 2.5 2.5 4.5 4.5 6.5 6.5 ...
## $ msfcEHR_T25FW.SPEED.AVG : num 3.6 3.6 3.4 3.4 4.4 4.4 4.4 4.4 6.6 6.6 ...
## $ FW_cadencestepsminmean : num 121 121 139 139 151 ...
## $ FW_singlesupportmean : num 32.5 32.5 38.9 38.9 39.9 ...
## $ FW_singlesupportratiolr : num 0.816 0.816 1.017 1.017 0.992 ...
## $ FW_stridetimeseccv : num 36.37 36.37 5.61 5.61 14.06 ...
## $ FW_stridetimesecmean : num 0.999 0.999 0.858 0.858 0.806 ...
## $ FW_stridewidthcmmean : num 5.55 5.55 6.85 6.85 9.31 ...
## $ FW_stridewidthcmsd : num 22.62 22.62 2.3 2.3 3.12 ...
## $ FW_totaldsupportmean : num 25.6 25.6 21.8 21.8 19.5 ...
## $ FW_totaldsupportratiolr : num 0.845 0.845 0.983 0.983 0.995 ...
## $ FW_velocitycmsecmean : num 123 123 190 190 205 ...
## $ PWS_cadencestepsminmean : num 116 116 112 112 127 ...
## $ PWS_singlesupportmean : num 34.8 34.8 35.8 35.8 36.9 ...
## $ PWS_singlesupportratiolr : num 0.952 0.952 1.038 1.038 1.02 ...
## $ PWS_stridetimeseccv : num 3.49 3.49 6.24 6.24 5.56 ...
## $ PWS_stridetimesecmean : num 1.028 1.028 1.065 1.065 0.945 ...
## $ PWS_stridewidthcmmean : num 8.19 8.19 8.33 8.33 8.69 ...
## $ PWS_stridewidthcmsd : num 3.72 3.72 2.38 2.38 1.95 ...
## $ PWS_totaldsupportmean : num 30.3 30.3 28.5 28.5 26.1 ...
## $ PWS_totaldsupportratiolr : num 1.01 1.01 0.98 0.98 1 ...
## $ PWS_velocitycmsecmean : num 137 137 116 116 140 ...
## $ redcap_event_name : Factor w/ 3 levels "Brainwalk: Baseline visit (Arm 1: Baseline visit)",..: 2 2 2 2 3 3 2 2 2 2 ...
## $ demographic_diagnosis : Factor w/ 1 level "MS": 1 1 1 1 1 1 1 1 1 1 ...
## $ bingoEHR_Vitals_height.in. : num 67 67 66 66 66 66 66 66 67 67 ...
## $ bingoEHR_first_MS.DX : chr "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" "RRMS (Relapsing-remitting Multiple Sclerosis)" ...
## $ edss_severity_num : num 2 2 2 2 2 2 3 3 3 3 ...
## $ edss_severity_cat : chr "moderate" "moderate" "moderate" "moderate" ...
## $ t25fw_group_num : num 1 1 1 1 1 1 1 1 2 2 ...
## $ t25fw_group_cat : chr "under_6" "under_6" "under_6" "under_6" ...
## $ race_ethnicity_clean : Factor w/ 5 levels "Asian","Black Or African American",..: 5 5 4 4 4 4 5 5 5 5 ...
## $ ms_dx_condensed : Factor w/ 3 levels "MS, Subtype Not Specified",..: 3 3 3 3 3 3 3 3 2 2 ...
## $ bw_hv_abs_date_diff : chr "0 days" "0 days" "9 days" "9 days" ...
# assign levels to categorical variables
table(home_df$race_ethnicity_clean)
##
## Asian Black Or African American Hispanic or Latino
## 4 2 2
## Other/Unknown/Declined White Not Hispanic
## 9 48
home_df$race_ethnicity_clean <- factor(home_df$race_ethnicity_clean,
levels = c('White Not Hispanic',
'Asian',
'Black Or African American',
'Hispanic or Latino',
'Other/Unknown/Declined'),
ordered = FALSE)
print(levels(home_df$race_ethnicity_clean))
## [1] "White Not Hispanic" "Asian"
## [3] "Black Or African American" "Hispanic or Latino"
## [5] "Other/Unknown/Declined"
table(home_df$ms_dx_condensed)
##
## MS, Subtype Not Specified Progressive MS RRMS
## 4 9 52
home_df$ms_dx_condensed <- factor(home_df$ms_dx_condensed,
levels = c('RRMS',
'Progressive MS',
'MS, Subtype Not Specified'),
ordered = FALSE)
print(levels(zeno_fw_df$ms_dx_condensed))
## [1] "RRMS" "Progressive MS"
## [3] "MS, Subtype Not Specified"
table(zeno_fw_df$clean_sex)
##
## Female Male Non-Binary
## 167 53 2
zeno_fw_df$clean_sex <- factor(zeno_fw_df$clean_sex,
levels = c('Female',
'Male',
'Non-Binary'),
ordered = FALSE)
print(levels(home_df$clean_sex))
## [1] "Female" "Male" "Non-Binary"
colSums(is.na(home_df))
## X
## 0
## video_id_date_name_pose_hv
## 0
## id_date_pose_hv
## 0
## task_pose_hv
## 0
## frames_per_second_pose_hv
## 0
## total_video_duration_sec_pose_hv
## 0
## delta_pix_h_rel_median_pose_hv
## 4
## walking_segmets_n_pose_hv
## 12
## walking_segments_duration_mean_pose_hv
## 12
## walking_segments_duration_median_pose_hv
## 12
## stride_time_mean_sec_pose_hv
## 13
## stride_time_median_sec_pose_hv
## 13
## stride_time_std_pose_hv
## 14
## stride_time_cv_pose_hv
## 14
## stride_time_max_pose_hv
## 13
## stride_time_min_pose_hv
## 13
## mean_cadence_step_per_min_pose_hv
## 12
## stride_width_mean_cm_pose_hv
## 12
## stride_width_median_cm_pose_hv
## 12
## stride_width_std_pose_hv
## 12
## stride_width_cv_pose_hv
## 12
## stride_width_max_pose_hv
## 12
## stride_width_min_pose_hv
## 12
## foot1_gait_cycle_time_mean_pose_hv
## 34
## foot1_stance_time_mean_pose_hv
## 34
## foot1_stance_per_mean_pose_hv
## 34
## foot1_swing_time_mean_pose_hv
## 34
## foot1_swing_per_mean_pose_hv
## 34
## foot1_ini_double_support_time_mean_pose_hv
## 34
## foot1_term_double_support_time_mean_pose_hv
## 34
## foot1_tot_double_support_time_mean_pose_hv
## 34
## foot1_double_support_per_mean_pose_hv
## 34
## foot1_single_support_time_mean_pose_hv
## 34
## foot1_single_support_per_mean_pose_hv
## 34
## walk_segment_pose_hv
## 34
## foot1_pose_hv
## 0
## id_video
## 0
## visit_date_video
## 0
## bw_id
## 0
## trialdate
## 0
## visit_date
## 0
## demoEHR_DiseaseDuration
## 0
## clean_sex
## 0
## clean_race
## 0
## clean_ethnicity
## 0
## demoEHR_Age
## 0
## bingoEHR_DX_MS.DX
## 0
## bingoEHR_EDSS_measure_value
## 0
## msfcEHR_T25FW.SPEED.AVG
## 0
## FW_cadencestepsminmean
## 0
## FW_singlesupportmean
## 0
## FW_singlesupportratiolr
## 0
## FW_stridetimeseccv
## 0
## FW_stridetimesecmean
## 0
## FW_stridewidthcmmean
## 0
## FW_stridewidthcmsd
## 0
## FW_totaldsupportmean
## 0
## FW_totaldsupportratiolr
## 0
## FW_velocitycmsecmean
## 0
## PWS_cadencestepsminmean
## 0
## PWS_singlesupportmean
## 0
## PWS_singlesupportratiolr
## 0
## PWS_stridetimeseccv
## 0
## PWS_stridetimesecmean
## 0
## PWS_stridewidthcmmean
## 0
## PWS_stridewidthcmsd
## 0
## PWS_totaldsupportmean
## 0
## PWS_totaldsupportratiolr
## 0
## PWS_velocitycmsecmean
## 0
## redcap_event_name
## 0
## demographic_diagnosis
## 0
## bingoEHR_Vitals_height.in.
## 4
## bingoEHR_first_MS.DX
## 0
## edss_severity_num
## 0
## edss_severity_cat
## 0
## t25fw_group_num
## 0
## t25fw_group_cat
## 0
## race_ethnicity_clean
## 0
## ms_dx_condensed
## 0
## bw_hv_abs_date_diff
## 0
# of right turning videos and left turning videos
table(home_df$task_pose_hv)
##
## gait_vertical_left gait_vertical_right
## 32 33
# videos per timepoint - most people sent two videos per timepoint
# some sent first videos at year 2 or year 3 visit, not necessarily follow up
table(home_df$redcap_event_name)
##
## Brainwalk: Baseline visit (Arm 1: Baseline visit)
## 38
## Year 2 Visit (Arm 1: Baseline visit)
## 23
## Year 3 Visit (Arm 1: Baseline visit)
## 4
all_univariate_mixed_effect <- function(data, outcome_column){
# remove hv or zv pattern in column name for consistency
colnames(data) <- gsub("pose_zv", "pose", colnames(data))
colnames(data) <- gsub("pose_hv", "pose", colnames(data))
################### video metrics ################################
# log delta pixel proxy ---------------------------------------------
print('log_delta_pix_h_rel_median_pose')
p <- ggplot(data = data,
aes(x = log_delta_pix_h_rel_median_pose,
y = .data[[outcome_column]])) +
geom_point()
print(p)
formula1 <- as.formula(paste(outcome_column,
"~ log_delta_pix_h_rel_median_pose + (1 | bw_id)"))
print(formula1)
uni1 <- lmer(formula1, data = data)
print(summary(uni1))
# Residuals vs. fitted values
hist(resid(uni1), main = "Residuals log_delta_pix_h_rel_median_pose")
# Normality check
qqnorm(residuals(uni1), main = "Normal Q-Q plot: log_delta_pix_h_rel_median_pose")
# uni df
uni1_df <- tidy(uni1, conf.int = TRUE) %>%
mutate(R2_conditional = r2(uni1)$R2_conditional) %>%
mutate(R2_marginal = r2(uni1)$R2_marginal) %>%
mutate(Variable = 'Log Pixel Height Proxy')
# stride time --------------------------------------------------------------
print('stride_time_median_sec_pose')
p <- ggplot(data = data,
aes(x = stride_time_median_sec_pose,
y = .data[[outcome_column]])) +
geom_point()
print(p)
formula2 <- as.formula(paste(outcome_column,
"~ stride_time_median_sec_pose + (1 | bw_id)"))
print(formula2)
uni2 <- lmer(formula2, data = data)
print(summary(uni2))
# Residuals vs. fitted values
hist(resid(uni2), main = "Residuals stride_time_median_sec_pose")
# Normality check
qqnorm(residuals(uni1), main = "Normal Q-Q plot: stride_time_median_sec_pose")
# uni df
uni2_df <- tidy(uni2, conf.int = TRUE) %>%
mutate(R2_conditional = r2(uni2)$R2_conditional) %>%
mutate(R2_marginal = r2(uni2)$R2_marginal) %>%
mutate(Variable = 'Stride Time - Median')
# cadence -------------------------------------------------------------------
print('mean_cadence_step_per_min_pose')
p <- ggplot(data = data,
aes(x = mean_cadence_step_per_min_pose,
y = .data[[outcome_column]])) +
geom_point()
print(p)
formula3 <- as.formula(paste(outcome_column,
"~ mean_cadence_step_per_min_pose + (1 | bw_id)"))
print(formula3)
uni3 <- lmer(formula3, data = data)
print(summary(uni3))
# Residuals vs. fitted values
hist(resid(uni3), main = "Residuals mean_cadence_step_per_min_pose")
# Normality check
qqnorm(residuals(uni3), main = "Normal Q-Q plot: mean_cadence_step_per_min_pose")
# uni df
uni3_df <- tidy(uni3, conf.int = TRUE) %>%
mutate(R2_conditional = r2(uni3)$R2_conditional) %>%
mutate(R2_marginal = r2(uni3)$R2_marginal) %>%
mutate(Variable = 'Cadence - Mean')
# stride width ----------------------------------------------------------
print('stride_width_median_cm_pose')
p <- ggplot(data = data,
aes(x = stride_width_median_cm_pose,
y = .data[[outcome_column]])) +
geom_point()
print(p)
formula4 <- as.formula(paste(outcome_column,
"~ stride_width_median_cm_pose + (1 | bw_id)"))
print(formula4)
uni4 <- lmer(formula4, data = data)
print(summary(uni4))
# Residuals vs. fitted values
hist(resid(uni4), main = "Residuals stride_width_median_cm_pose")
# Normality check
qqnorm(residuals(uni4), main = "Normal Q-Q plot: stride_width_median_cm_pose")
# uni df
uni4_df <- tidy(uni4, conf.int = TRUE) %>%
mutate(R2_conditional = r2(uni4)$R2_conditional) %>%
mutate(R2_marginal = r2(uni4)$R2_marginal) %>%
mutate(Variable = 'Stride Width - Median')
#### demographics and MS info ##################
# Age ---------------------------------------------
print('demoEHR_Age')
p <- ggplot(data = data,
aes(x = demoEHR_Age,
y = .data[[outcome_column]])) +
geom_point()
print(p)
formula5 <- as.formula(paste(outcome_column,
"~ demoEHR_Age + (1 | bw_id)"))
print(formula5)
uni5 <- lmer(formula5, data = data)
print(summary(uni5))
# Residuals vs. fitted values
hist(resid(uni5), main = "Residuals demoEHR_Age")
# Normality check
qqnorm(residuals(uni5), main = "Normal Q-Q plot: demoEHR_Age")
# uni df
uni5_df <- tidy(uni5, conf.int = TRUE) %>%
mutate(R2_conditional = r2(uni5)$R2_conditional) %>%
mutate(R2_marginal = r2(uni5)$R2_marginal) %>%
mutate(Variable = 'Age')
# Disease Duration ---------------------------------------------
print('demoEHR_DiseaseDuration')
p <- ggplot(data = data,
aes(x = demoEHR_DiseaseDuration,
y = .data[[outcome_column]])) +
geom_point()
print(p)
formula6 <- as.formula(paste(outcome_column,
"~ demoEHR_DiseaseDuration + (1 | bw_id)"))
print(formula6)
uni6 <- lmer(formula6, data = data)
print(summary(uni6))
# Residuals vs. fitted values
hist(resid(uni6), main = "Residuals demoEHR_DiseaseDuration")
# Normality check
qqnorm(residuals(uni6), main = "Normal Q-Q plot: demoEHR_DiseaseDuration")
# uni df
uni6_df <- tidy(uni6, conf.int = TRUE) %>%
mutate(R2_conditional = r2(uni6)$R2_conditional) %>%
mutate(R2_marginal = r2(uni6)$R2_marginal) %>%
mutate(Variable = 'Disease Duration')
# MS DX ---------------------------------------------
print('ms_dx_condensed')
formula7 <- as.formula(paste(outcome_column,
"~ ms_dx_condensed + (1 | bw_id)"))
print(formula7)
uni7 <- lmer(formula7, data = data)
print(summary(uni7))
# Residuals vs. fitted values
hist(resid(uni7), main = "Residuals ms_dx_condensed")
# Normality check
qqnorm(residuals(uni7), main = "Normal Q-Q plot: ms_dx_condensed")
# uni df
uni7_df <- tidy(uni7, conf.int = TRUE) %>%
mutate(R2_conditional = r2(uni7)$R2_conditional) %>%
mutate(R2_marginal = r2(uni7)$R2_marginal) %>%
mutate(Variable = 'MS DX')
# Race and Ethnicity ---------------------------------------------
print('race_ethnicity_clean')
formula8 <- as.formula(paste(outcome_column,
"~ race_ethnicity_clean + (1 | bw_id)"))
print(formula8)
uni8 <- lmer(formula8, data = data)
print(summary(uni8))
# Residuals vs. fitted values
hist(resid(uni8), main = "Residuals race_ethnicity_clean")
# Normality check
qqnorm(residuals(uni8), main = "Normal Q-Q plot: race_ethnicity_clean")
# uni df
uni8_df <- tidy(uni8, conf.int = TRUE) %>%
mutate(R2_conditional = r2(uni8)$R2_conditional) %>%
mutate(R2_marginal = r2(uni8)$R2_marginal) %>%
mutate(Variable = 'Race and Ethnicity')
# Sex ---------------------------------------------
print('clean_sex')
formula9 <- as.formula(paste(outcome_column,
"~ clean_sex + (1 | bw_id)"))
print(formula9)
uni9 <- lmer(formula9, data = data)
print(summary(uni9))
# Residuals vs. fitted values
hist(resid(uni9), main = "Residuals clean_sex")
# Normality check
qqnorm(residuals(uni9), main = "Normal Q-Q plot: clean_sex")
# uni df
uni9_df <- tidy(uni9, conf.int = TRUE) %>%
mutate(R2_conditional = r2(uni9)$R2_conditional) %>%
mutate(R2_marginal = r2(uni9)$R2_marginal) %>%
mutate(Variable = 'Sex')
# tidy and bind all together --------------------------------
tidy_uni_df <- bind_rows(uni1_df, uni2_df, uni3_df, uni4_df,
uni5_df, uni6_df, uni7_df, uni8_df,
uni9_df) %>%
mutate(Model = "Univariate Unadjusted")
return(tidy_uni_df)
}
# Conditional rounding function
format_p_value <- function(p) {
if (p < 0.001) {
return(formatC(p, format = "e", digits = 1)) # Scientific notation, 1 decimal place
} else {
return(formatC(p, format = "f", digits = 2)) # Standard notation, 2 decimal places
}
}
Should work for univariate or multivariate models - plot each variable as diff color Significance based transparency
univariate_regression_plot <- function(results, plot_title, x_adj) {
# Filter rows
results <- results %>%
filter(effect != 'ran_pars') %>%
filter(term != '(Intercept)')
results$Variable <- factor(results$Variable)
# Apply rounding function to p-value columns
results <- results %>% mutate(pval_text = paste0("p=", sapply(p.value, format_p_value))) # Format p-values
# Apply formatting function and create significance indicators
results <- results %>%
mutate(
pval_text = paste0("p=", sapply(p.value, format_p_value)),
sig = ifelse(p.value < 0.05, "Significant", "Non-Significant"), # Create significance group
alpha_level = ifelse(p.value < 0.05, 1, 0.3) # More transparency for non-sig points
)
# Determine x position for p-values (offset to the right of the max estimate)
x_max <- max(results$conf.high, na.rm = TRUE) # Get max confidence interval upper bound
results <- results %>% mutate(pval_x_pos = x_max + x_adj) # Place p-values slightly to the right of max x range
p <- ggplot(results, aes(x = estimate, y = term, color = Variable, alpha = alpha_level))+
geom_point(size = 3) + # dot = coefficient estimate
geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0.2) + # Whiskers for confidence intervals
geom_text(aes(x = pval_x_pos, label = pval_text, fontface = ifelse(p.value < 0.05, "bold", "plain")),
hjust = 1, size = 3) + # Right-aligned p-values, bold if significant
scale_alpha_identity() + # Use manually set alpha levels
geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") + # Reference line at zero
theme_minimal() +
labs(title = plot_title,
x = "Estimate (Effect Size)",
y = "Predictor") +
theme(legend.position = "right") # Hide legend to keep it clean
return(p)
}
adj_vs_unadj_plot <- function(results_df, plot_title, x_adj){
set.seed(42) # Set seed for reproducibility
# Filter rows
results_df <- results_df %>%
filter(effect != 'ran_pars') %>%
filter(term != '(Intercept)')
results_df <- results_df %>%
mutate(
pval_text = paste0("p=", sapply(p.value, format_p_value)), # Format p-values
sig = ifelse(is.na(p.value) | p.value >= 0.05, "Non-Significant", "Significant"), # Identify significance
alpha_level = ifelse(is.na(p.value) | p.value >= 0.05, 0.3, 1), # More transparency for non-sig points
jitter_y = as.numeric(factor(term)) + runif(n(), -0.2, 0.2) # Jitter y-axis values slightly
)
# Define colors for models
model_colors <- c("Unadjusted - Multivariate Demographics and MS Info" = "darkgreen",
"Unadjusted - Multivariate Video Metrics" = "darkblue",
"Adjusted - Multivariate Video Metrics" = "darkorange")
# Define shading by creating an index for each predictor group
results_df <- results_df %>%
arrange(term) %>%
mutate(group = as.integer(factor(term)) %% 2) # Alternating shading
# Determine x position for p-values (offset to the right of max estimate)
x_max <- max(results_df$conf.high, na.rm = TRUE) # Get max confidence interval upper bound
results_df <- results_df %>%
mutate(pval_x_pos = x_max + x_adj) # Place p-values slightly to the right of max x range
# Dot-and-whisker plot with enhancements
p <- ggplot(results_df, aes(x = estimate, y = term, color = Model, alpha = alpha_level)) +
# Add confidence intervals as horizontal whiskers
geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0.2,
position = position_dodge(width = 0.5)) +
# Add dots for coefficient estimates
geom_point(position = position_dodge(width = 0.5), size = 3) +
# Add background shading for alternate rows
geom_rect(data = results_df, aes(ymin = as.numeric(factor(term)) - 0.5,
ymax = as.numeric(factor(term)) + 0.5,
xmin = -Inf, xmax = Inf,
fill = factor(group)),
inherit.aes = FALSE, alpha = 0.1) +
# Add vertical line at zero (null effect)
geom_vline(xintercept = 0, linetype = "dashed", color = "gray50") +
# Add jittered p-values at right side
geom_text(aes(x = pval_x_pos, y = jitter_y, label = pval_text,
fontface = ifelse(sig == "Significant", "bold", "plain")),
hjust = 1, size = 3) +
scale_color_manual(values = model_colors) + # Set custom colors for models
scale_fill_manual(values = c("white", "gray90")) + # Alternating shading
scale_alpha_identity() + # Use manually set alpha levels
theme_minimal() +
labs(title = plot_title,
x = "Estimate (Effect Size)",
y = "Predictor",
color = "Model") +
theme(legend.position = "right", # Move legend to the right
panel.grid.major = element_blank(), # Remove major grid lines for clarity
panel.grid.minor = element_blank())
return(p)
}
# preferred walking speed
ggplot(data = zeno_pws_df, mapping = aes(msfcEHR_T25FW.SPEED.AVG)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# log transform
zeno_pws_df$t25fw_log <- log(zeno_pws_df$msfcEHR_T25FW.SPEED.AVG)
ggplot(data = zeno_pws_df, mapping = aes(t25fw_log)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# inverse transformation
zeno_pws_df$t25fw_inverse <- 1/zeno_pws_df$msfcEHR_T25FW.SPEED.AVG
ggplot(data = zeno_pws_df, mapping = aes(t25fw_inverse)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# square root
zeno_pws_df$t25fw_sqrt <- scale(zeno_pws_df$msfcEHR_T25FW.SPEED.AVG)
ggplot(data = zeno_pws_df, mapping = aes(t25fw_sqrt)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Fast walking speed
ggplot(data = zeno_fw_df, mapping = aes(msfcEHR_T25FW.SPEED.AVG)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# log transform
zeno_fw_df$t25fw_log <- log(zeno_fw_df$msfcEHR_T25FW.SPEED.AVG)
ggplot(data = zeno_fw_df, mapping = aes(t25fw_log)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# inverse transformation
zeno_fw_df$t25fw_inverse <- 1/zeno_fw_df$msfcEHR_T25FW.SPEED.AVG
ggplot(data = zeno_fw_df, mapping = aes(t25fw_inverse)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# square root
zeno_fw_df$t25fw_sqrt <- scale(zeno_fw_df$msfcEHR_T25FW.SPEED.AVG)
ggplot(data = zeno_fw_df, mapping = aes(t25fw_sqrt)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Home Videos
ggplot(data = home_df, mapping = aes(msfcEHR_T25FW.SPEED.AVG)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# log transform
home_df$t25fw_log <- log(home_df$msfcEHR_T25FW.SPEED.AVG)
ggplot(data = home_df, mapping = aes(t25fw_log)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# inverse transformation
home_df$t25fw_inverse <- 1/home_df$msfcEHR_T25FW.SPEED.AVG
ggplot(data = home_df, mapping = aes(t25fw_inverse)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# square root
home_df$t25fw_sqrt <- scale(home_df$msfcEHR_T25FW.SPEED.AVG)
ggplot(data = home_df, mapping = aes(t25fw_sqrt)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
log transform to improve linearity and replace inf values with NA
zeno_pws_df$log_delta_pix_h_rel_median_pose_zv <- log(zeno_pws_df$delta_pix_h_rel_median_pose_zv)
zeno_fw_df$log_delta_pix_h_rel_median_pose_zv <- log(zeno_fw_df$delta_pix_h_rel_median_pose_zv)
home_df$log_delta_pix_h_rel_median_pose_hv <- log(home_df$delta_pix_h_rel_median_pose_hv)
# convert inf to NaN
zeno_pws_df[] <- lapply(zeno_pws_df, function(x) {
if (is.numeric(x)) replace(x, is.infinite(x), NA) else x
})
zeno_fw_df[] <- lapply(zeno_fw_df, function(x) {
if (is.numeric(x)) replace(x, is.infinite(x), NA) else x
})
home_df[] <- lapply(home_df, function(x) {
if (is.numeric(x)) replace(x, is.infinite(x), NA) else x
})
Outcome = Inverse Transform T25FW
uni_zv_pws_t25fw_inv <- all_univariate_mixed_effect(data = zeno_pws_df,
outcome_column = "t25fw_inverse")
## [1] "log_delta_pix_h_rel_median_pose"
## Warning: Removed 16 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ log_delta_pix_h_rel_median_pose + (1 | bw_id)
## <environment: 0x00000000268c9580>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula1
## Data: data
##
## REML criterion at convergence: -600
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.83368 -0.39416 -0.03095 0.34483 2.86758
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.002341 0.04839
## Residual 0.001201 0.03466
## Number of obs: 208, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.659e-01 1.111e-02 1.850e+02 23.940 < 2e-16
## log_delta_pix_h_rel_median_pose 4.113e-02 7.094e-03 1.571e+02 5.799 3.56e-08
##
## (Intercept) ***
## log_delta_pix_h_rel_median_pose ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## lg_dlt_____ 0.909
## [1] "stride_time_median_sec_pose"
## Warning: Removed 48 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ stride_time_median_sec_pose + (1 | bw_id)
## <environment: 0x00000000268c9580>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula2
## Data: data
##
## REML criterion at convergence: -526.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.66578 -0.34600 -0.03032 0.35330 2.62490
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0031003 0.05568
## Residual 0.0006519 0.02553
## Number of obs: 176, groups: bw_id, 128
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.25985 0.02404 84.00144 10.811 <2e-16 ***
## stride_time_median_sec_pose -0.04480 0.02077 76.73797 -2.157 0.0341 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_tm_m__ -0.975
## [1] "mean_cadence_step_per_min_pose"
## Warning: Removed 40 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ mean_cadence_step_per_min_pose + (1 | bw_id)
## <environment: 0x00000000268c9580>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula3
## Data: data
##
## REML criterion at convergence: -535.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.77459 -0.32654 -0.02616 0.31830 2.74396
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0035632 0.05969
## Residual 0.0005904 0.02430
## Number of obs: 184, groups: bw_id, 132
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.824e-01 2.479e-02 1.022e+02 7.357 4.86e-11
## mean_cadence_step_per_min_pose 2.433e-04 2.341e-04 9.411e+01 1.039 0.301
##
## (Intercept) ***
## mean_cadence_step_per_min_pose
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mn_cdnc____ -0.975
## [1] "stride_width_median_cm_pose"
## Warning: Removed 40 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ stride_width_median_cm_pose + (1 | bw_id)
## <environment: 0x00000000268c9580>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula4
## Data: data
##
## REML criterion at convergence: -540.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.89660 -0.32519 -0.04361 0.32861 2.66680
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0034537 0.05877
## Residual 0.0006053 0.02460
## Number of obs: 184, groups: bw_id, 132
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.231562 0.014382 135.062508 16.100 <2e-16
## stride_width_median_cm_pose -0.001913 0.001059 109.991321 -1.807 0.0735
##
## (Intercept) ***
## stride_width_median_cm_pose .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_wdt___ -0.925
## [1] "demoEHR_Age"
## t25fw_inverse ~ demoEHR_Age + (1 | bw_id)
## <environment: 0x00000000268c9580>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula5
## Data: data
##
## REML criterion at convergence: -658
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.39844 -0.34548 -0.01678 0.30502 2.52497
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0032803 0.05727
## Residual 0.0007357 0.02712
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.29148 0.02021 154.61031 14.422 < 2e-16 ***
## demoEHR_Age -0.00168 0.00039 155.26252 -4.308 2.91e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## demoEHR_Age -0.969
## [1] "demoEHR_DiseaseDuration"
## t25fw_inverse ~ demoEHR_DiseaseDuration + (1 | bw_id)
## <environment: 0x00000000268c9580>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula6
## Data: data
##
## REML criterion at convergence: -644.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.39967 -0.32293 -0.02153 0.27398 2.52378
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0036742 0.06061
## Residual 0.0007357 0.02712
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.178e-01 8.356e-03 1.567e+02 26.061 <2e-16 ***
## demoEHR_DiseaseDuration -1.095e-03 6.655e-04 1.579e+02 -1.645 0.102
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## dmEHR_DssDr -0.778
## [1] "ms_dx_condensed"
## t25fw_inverse ~ ms_dx_condensed + (1 | bw_id)
## <environment: 0x00000000268c9580>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula7
## Data: data
##
## REML criterion at convergence: -680.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.41935 -0.35078 -0.02125 0.34332 2.53863
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0028517 0.05340
## Residual 0.0007254 0.02693
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.222026 0.005262 152.754170
## ms_dx_condensedProgressive MS -0.078743 0.012093 155.073859
## ms_dx_condensedMS, Subtype Not Specified -0.010473 0.041482 151.165385
## t value Pr(>|t|)
## (Intercept) 42.195 < 2e-16 ***
## ms_dx_condensedProgressive MS -6.511 9.81e-10 ***
## ms_dx_condensedMS, Subtype Not Specified -0.252 0.801
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) m__PMS
## ms_dx_cnPMS -0.435
## ms_d_MS,SNS -0.127 0.055
## [1] "race_ethnicity_clean"
## t25fw_inverse ~ race_ethnicity_clean + (1 | bw_id)
## <environment: 0x00000000268c9580>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula8
## Data: data
##
## REML criterion at convergence: -638.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.41228 -0.29878 -0.02029 0.27321 2.51217
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0036120 0.06010
## Residual 0.0007354 0.02712
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 2.116e-01 6.307e-03 1.492e+02
## race_ethnicity_cleanAsian -2.405e-02 2.044e-02 1.481e+02
## race_ethnicity_cleanBlack Or African American -5.186e-02 2.062e-02 1.534e+02
## race_ethnicity_cleanHispanic or Latino 8.896e-04 1.787e-02 1.503e+02
## race_ethnicity_cleanOther/Unknown/Declined 1.002e-02 1.969e-02 1.491e+02
## t value Pr(>|t|)
## (Intercept) 33.549 <2e-16 ***
## race_ethnicity_cleanAsian -1.176 0.2413
## race_ethnicity_cleanBlack Or African American -2.515 0.0129 *
## race_ethnicity_cleanHispanic or Latino 0.050 0.9604
## race_ethnicity_cleanOther/Unknown/Declined 0.509 0.6117
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rc_t_A r__OAA r__HoL
## rc_thncty_A -0.309
## rc_thn_BOAA -0.306 0.094
## rc_thnc_HoL -0.353 0.109 0.108
## rc_th_O/U/D -0.320 0.099 0.098 0.113
## [1] "clean_sex"
## t25fw_inverse ~ clean_sex + (1 | bw_id)
## <environment: 0x00000000268c9580>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula9
## Data: data
##
## REML criterion at convergence: -644.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.3582 -0.3165 -0.0239 0.2809 2.5705
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0037550 0.06128
## Residual 0.0007341 0.02709
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.040e-01 6.131e-03 1.517e+02 33.269 <2e-16 ***
## clean_sexMale 1.226e-02 1.231e-02 1.522e+02 0.996 0.321
## clean_sexNon-Binary 1.132e-02 6.449e-02 1.382e+02 0.175 0.861
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) cln_sM
## clean_sexMl -0.498
## cln_sxNn-Bn -0.095 0.047
# save adjusted r_squared
adj_r_squared_df <- uni_zv_pws_t25fw_inv[c('Variable', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 9 x 3
## Variable R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Log Pixel Height Proxy 0.7 0.11
## 2 Stride Time - Median 0.83 0.01
## 3 Cadence - Mean 0.86 0
## 4 Stride Width - Median 0.85 0.01
## 5 Age 0.83 0.1
## 6 Disease Duration 0.84 0.02
## 7 MS DX 0.84 0.2
## 8 Race and Ethnicity 0.84 0.04
## 9 Sex 0.84 0.01
write.csv(adj_r_squared_df, file.path(output_dir, 't25fw_inverse_univariate_pws_r2.csv'))
# Plot estimates
p <- univariate_regression_plot(results = uni_zv_pws_t25fw_inv,
plot_title = "PWS Univariate - lmer(Inverse T25FW ~ Predictor + (1 | bw_id))",
x_adj = 0.1)
p
ggsave(file.path(output_dir, 't25fw_inverse_univariate_pws_estimates.png'),
bg = "white", width= 10, height=10)
Not all metrics could be calculated from each video metric
Dropped videos missing any video metric so models could be compared
zeno_pws_clean_df <- zeno_pws_df %>%
drop_na(c("stride_time_median_sec_pose_zv",
"log_delta_pix_h_rel_median_pose_zv",
"mean_cadence_step_per_min_pose_zv",
"stride_width_median_cm_pose_zv"))
colSums(is.na(zeno_pws_clean_df))
## X
## 0
## video_id_date_name_pose_zv
## 0
## id_date_pose_zv
## 0
## task_pose_zv
## 0
## frames_per_second_pose_zv
## 0
## total_video_duration_sec_pose_zv
## 0
## delta_pix_h_rel_median_pose_zv
## 0
## walking_segmets_n_pose_zv
## 0
## walking_segments_duration_mean_pose_zv
## 0
## walking_segments_duration_median_pose_zv
## 0
## stride_time_mean_sec_pose_zv
## 0
## stride_time_median_sec_pose_zv
## 0
## stride_time_std_pose_zv
## 5
## stride_time_cv_pose_zv
## 5
## stride_time_max_pose_zv
## 0
## stride_time_min_pose_zv
## 0
## mean_cadence_step_per_min_pose_zv
## 0
## stride_width_mean_cm_pose_zv
## 0
## stride_width_median_cm_pose_zv
## 0
## stride_width_std_pose_zv
## 1
## stride_width_cv_pose_zv
## 1
## stride_width_max_pose_zv
## 0
## stride_width_min_pose_zv
## 0
## foot1_gait_cycle_time_mean_pose_zv
## 109
## foot1_stance_time_mean_pose_zv
## 109
## foot1_stance_per_mean_pose_zv
## 109
## foot1_swing_time_mean_pose_zv
## 109
## foot1_swing_per_mean_pose_zv
## 109
## foot1_ini_double_support_time_mean_pose_zv
## 109
## foot1_term_double_support_time_mean_pose_zv
## 109
## foot1_tot_double_support_time_mean_pose_zv
## 109
## foot1_double_support_per_mean_pose_zv
## 109
## foot1_single_support_time_mean_pose_zv
## 109
## foot1_single_support_per_mean_pose_zv
## 109
## walk_segment_pose_zv
## 109
## foot1_pose_zv
## 0
## id_video
## 0
## visit_date_video
## 0
## bw_id
## 0
## trialdate
## 0
## visit_date
## 0
## demoEHR_DiseaseDuration
## 0
## clean_sex
## 0
## clean_race
## 0
## clean_ethnicity
## 0
## demoEHR_Age
## 0
## bingoEHR_DX_MS.DX
## 0
## bingoEHR_EDSS_measure_value
## 0
## msfcEHR_T25FW.SPEED.AVG
## 0
## FW_cadencestepsminmean
## 0
## FW_singlesupportmean
## 0
## FW_singlesupportratiolr
## 0
## FW_stridetimeseccv
## 0
## FW_stridetimesecmean
## 0
## FW_stridewidthcmmean
## 0
## FW_stridewidthcmsd
## 0
## FW_totaldsupportmean
## 0
## FW_totaldsupportratiolr
## 0
## FW_velocitycmsecmean
## 0
## PWS_cadencestepsminmean
## 0
## PWS_singlesupportmean
## 0
## PWS_singlesupportratiolr
## 0
## PWS_stridetimeseccv
## 0
## PWS_stridetimesecmean
## 0
## PWS_stridewidthcmmean
## 0
## PWS_stridewidthcmsd
## 0
## PWS_totaldsupportmean
## 0
## PWS_totaldsupportratiolr
## 0
## PWS_velocitycmsecmean
## 0
## redcap_event_name
## 0
## demographic_diagnosis
## 0
## bingoEHR_Vitals_height.in.
## 11
## bingoEHR_first_MS.DX
## 0
## edss_severity_num
## 0
## edss_severity_cat
## 0
## t25fw_group_num
## 0
## t25fw_group_cat
## 0
## race_ethnicity_clean
## 0
## ms_dx_condensed
## 0
## t25fw_log
## 0
## t25fw_inverse
## 0
##
## 0
## log_delta_pix_h_rel_median_pose_zv
## 0
t25fw_pws_multi_dem <- lmer(t25fw_inverse ~
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = zeno_pws_clean_df)
summary(t25fw_pws_multi_dem)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## t25fw_inverse ~ demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: zeno_pws_clean_df
##
## REML criterion at convergence: -435.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.59107 -0.35899 -0.00299 0.32896 2.56814
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0024740 0.04974
## Residual 0.0006878 0.02623
## Number of obs: 162, groups: bw_id, 127
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 2.937e-01 2.458e-02 1.165e+02
## demoEHR_Age -1.347e-03 5.060e-04 1.188e+02
## demoEHR_DiseaseDuration 3.413e-05 7.191e-04 1.181e+02
## ms_dx_condensedProgressive MS -5.618e-02 1.438e-02 1.181e+02
## ms_dx_condensedMS, Subtype Not Specified 7.201e-03 4.113e-02 1.231e+02
## race_ethnicity_cleanAsian -3.828e-02 2.119e-02 1.180e+02
## race_ethnicity_cleanBlack Or African American -7.868e-02 1.943e-02 1.138e+02
## race_ethnicity_cleanHispanic or Latino -1.357e-02 1.728e-02 1.160e+02
## race_ethnicity_cleanOther/Unknown/Declined -2.256e-02 2.180e-02 1.187e+02
## clean_sexMale 7.427e-03 1.146e-02 1.176e+02
## clean_sexNon-Binary -9.488e-03 5.706e-02 1.234e+02
## t value Pr(>|t|)
## (Intercept) 11.947 < 2e-16 ***
## demoEHR_Age -2.662 0.008854 **
## demoEHR_DiseaseDuration 0.047 0.962222
## ms_dx_condensedProgressive MS -3.906 0.000157 ***
## ms_dx_condensedMS, Subtype Not Specified 0.175 0.861319
## race_ethnicity_cleanAsian -1.807 0.073326 .
## race_ethnicity_cleanBlack Or African American -4.050 9.38e-05 ***
## race_ethnicity_cleanHispanic or Latino -0.785 0.433864
## race_ethnicity_cleanOther/Unknown/Declined -1.035 0.302815
## clean_sexMale 0.648 0.518264
## clean_sexNon-Binary -0.166 0.868205
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) dEHR_A dEHR_D m__PMS m__SNS rc_t_A r__OAA r__HoL r__O/U
## demoEHR_Age -0.920
## dmEHR_DssDr 0.183 -0.454
## ms_dx_cnPMS 0.119 -0.180 -0.120
## ms_d_MS,SNS 0.130 -0.142 -0.047 0.115
## rc_thncty_A -0.285 0.217 -0.033 -0.012 0.008
## rc_thn_BOAA -0.164 0.077 -0.003 0.038 0.031 0.107
## rc_thnc_HoL -0.315 0.238 -0.046 0.031 0.023 0.167 0.129
## rc_th_O/U/D -0.353 0.254 -0.033 0.053 -0.009 0.136 0.117 0.154
## clean_sexMl -0.153 0.032 0.002 0.004 -0.075 -0.053 0.027 -0.126 0.144
## cln_sxNn-Bn -0.056 -0.012 0.107 0.022 0.002 0.034 0.039 0.039 0.049
## cln_sM
## demoEHR_Age
## dmEHR_DssDr
## ms_dx_cnPMS
## ms_d_MS,SNS
## rc_thncty_A
## rc_thn_BOAA
## rc_thnc_HoL
## rc_th_O/U/D
## clean_sexMl
## cln_sxNn-Bn 0.053
# Residuals vs. fitted values
hist(resid(t25fw_pws_multi_dem), main = "Residuals All Demographic and MS Info")
# Normality check
qqnorm(residuals(t25fw_pws_multi_dem), main = "Normal Q-Q plot: Residuals All Demographic and MS Info")
# tidy results
t25fw_pws_multi_dem_df <- tidy(t25fw_pws_multi_dem, conf.int = TRUE) %>%
mutate(R2_conditional = r2(t25fw_pws_multi_dem)$R2_conditional) %>%
mutate(R2_marginal = r2(t25fw_pws_multi_dem)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Demographics and MS Info")
t25fw_pws_multi_dem_df
## # A tibble: 13 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Int~ 2.94e-1 0.0246 11.9 116. 5.79e-22 0.245
## 2 fixed <NA> demo~ -1.35e-3 0.000506 -2.66 119. 8.85e- 3 -0.00235
## 3 fixed <NA> demo~ 3.41e-5 0.000719 0.0475 118. 9.62e- 1 -0.00139
## 4 fixed <NA> ms_d~ -5.62e-2 0.0144 -3.91 118. 1.57e- 4 -0.0847
## 5 fixed <NA> ms_d~ 7.20e-3 0.0411 0.175 123. 8.61e- 1 -0.0742
## 6 fixed <NA> race~ -3.83e-2 0.0212 -1.81 118. 7.33e- 2 -0.0802
## 7 fixed <NA> race~ -7.87e-2 0.0194 -4.05 114. 9.38e- 5 -0.117
## 8 fixed <NA> race~ -1.36e-2 0.0173 -0.785 116. 4.34e- 1 -0.0478
## 9 fixed <NA> race~ -2.26e-2 0.0218 -1.03 119. 3.03e- 1 -0.0657
## 10 fixed <NA> clea~ 7.43e-3 0.0115 0.648 118. 5.18e- 1 -0.0153
## 11 fixed <NA> clea~ -9.49e-3 0.0571 -0.166 123. 8.68e- 1 -0.122
## 12 ran_pars bw_id sd__~ 4.97e-2 NA NA NA NA NA
## 13 ran_pars Residual sd__~ 2.62e-2 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
t25fw_pws_multi_vid_unadj <- lmer(t25fw_inverse ~
stride_time_median_sec_pose_zv +
log_delta_pix_h_rel_median_pose_zv +
mean_cadence_step_per_min_pose_zv +
stride_width_median_cm_pose_zv +
(1|bw_id),
data = zeno_pws_clean_df)
summary(t25fw_pws_multi_vid_unadj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv +
## mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv +
## (1 | bw_id)
## Data: zeno_pws_clean_df
##
## REML criterion at convergence: -449.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.8105 -0.3820 -0.0337 0.3811 2.8204
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.002209 0.04700
## Residual 0.001025 0.03201
## Number of obs: 162, groups: bw_id, 127
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 3.695e-01 7.623e-02 9.810e+01 4.848
## stride_time_median_sec_pose_zv -7.166e-02 3.423e-02 8.938e+01 -2.093
## log_delta_pix_h_rel_median_pose_zv 2.007e-02 8.571e-03 1.025e+02 2.341
## mean_cadence_step_per_min_pose_zv 9.103e-06 4.087e-04 9.721e+01 0.022
## stride_width_median_cm_pose_zv -4.111e-03 1.355e-03 1.530e+02 -3.033
## Pr(>|t|)
## (Intercept) 4.68e-06 ***
## stride_time_median_sec_pose_zv 0.03915 *
## log_delta_pix_h_rel_median_pose_zv 0.02116 *
## mean_cadence_step_per_min_pose_zv 0.98228
## stride_width_median_cm_pose_zv 0.00284 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) strd_t____ l_____ m_____
## strd_tm____ -0.800
## lg_dl______ 0.116 0.202
## mn_cdn_____ -0.891 0.550 -0.136
## strd_wd____ -0.326 0.083 0.084 0.131
# Residuals vs. fitted values
hist(resid(t25fw_pws_multi_vid_unadj), main = "Residuals All Video Metrics Unadjusted")
# Normality check
qqnorm(residuals(t25fw_pws_multi_vid_unadj), main = "Normal Q-Q plot: Residuals All Video Metrics Unadjusted")
# tidy results
t25fw_pws_multi_vid_unadj_df <- tidy(t25fw_pws_multi_vid_unadj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(t25fw_pws_multi_vid_unadj)$R2_conditional) %>%
mutate(R2_marginal = r2(t25fw_pws_multi_vid_unadj)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Video Metrics")
t25fw_pws_multi_vid_unadj_df
## # A tibble: 7 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inter~ 3.70e-1 0.0762 4.85 98.1 4.68e-6 2.18e-1
## 2 fixed <NA> stride~ -7.17e-2 0.0342 -2.09 89.4 3.92e-2 -1.40e-1
## 3 fixed <NA> log_de~ 2.01e-2 0.00857 2.34 103. 2.12e-2 3.07e-3
## 4 fixed <NA> mean_c~ 9.10e-6 0.000409 0.0223 97.2 9.82e-1 -8.02e-4
## 5 fixed <NA> stride~ -4.11e-3 0.00136 -3.03 153. 2.84e-3 -6.79e-3
## 6 ran_pars bw_id sd__(I~ 4.70e-2 NA NA NA NA NA
## 7 ran_pars Residual sd__Ob~ 3.20e-2 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
t25fw_pws_multi_vid_adj <- lmer(t25fw_inverse ~
stride_time_median_sec_pose_zv +
log_delta_pix_h_rel_median_pose_zv +
mean_cadence_step_per_min_pose_zv +
stride_width_median_cm_pose_zv +
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = zeno_pws_clean_df)
summary(t25fw_pws_multi_vid_adj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv +
## mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv +
## demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: zeno_pws_clean_df
##
## REML criterion at convergence: -410
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.02262 -0.42154 -0.01768 0.38626 2.87797
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0016891 0.04110
## Residual 0.0009969 0.03157
## Number of obs: 162, groups: bw_id, 127
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 3.719e-01 7.889e-02 1.040e+02
## stride_time_median_sec_pose_zv -4.763e-02 3.365e-02 8.893e+01
## log_delta_pix_h_rel_median_pose_zv 1.681e-02 8.419e-03 9.883e+01
## mean_cadence_step_per_min_pose_zv 2.970e-04 3.993e-04 9.346e+01
## stride_width_median_cm_pose_zv -2.346e-03 1.364e-03 1.458e+02
## demoEHR_Age -1.474e-03 4.631e-04 1.102e+02
## demoEHR_DiseaseDuration -6.427e-05 6.634e-04 1.065e+02
## ms_dx_condensedProgressive MS -3.057e-02 1.476e-02 1.187e+02
## ms_dx_condensedMS, Subtype Not Specified 6.442e-03 3.805e-02 1.217e+02
## race_ethnicity_cleanAsian -3.325e-02 1.965e-02 1.123e+02
## race_ethnicity_cleanBlack Or African American -7.274e-02 1.793e-02 1.040e+02
## race_ethnicity_cleanHispanic or Latino -1.697e-02 1.578e-02 1.057e+02
## race_ethnicity_cleanOther/Unknown/Declined -1.820e-02 2.017e-02 1.149e+02
## clean_sexMale 1.041e-02 1.072e-02 1.123e+02
## clean_sexNon-Binary -1.608e-02 5.271e-02 1.220e+02
## t value Pr(>|t|)
## (Intercept) 4.714 7.57e-06 ***
## stride_time_median_sec_pose_zv -1.416 0.1604
## log_delta_pix_h_rel_median_pose_zv 1.996 0.0487 *
## mean_cadence_step_per_min_pose_zv 0.744 0.4588
## stride_width_median_cm_pose_zv -1.720 0.0876 .
## demoEHR_Age -3.182 0.0019 **
## demoEHR_DiseaseDuration -0.097 0.9230
## ms_dx_condensedProgressive MS -2.071 0.0405 *
## ms_dx_condensedMS, Subtype Not Specified 0.169 0.8658
## race_ethnicity_cleanAsian -1.692 0.0934 .
## race_ethnicity_cleanBlack Or African American -4.058 9.61e-05 ***
## race_ethnicity_cleanHispanic or Latino -1.076 0.2846
## race_ethnicity_cleanOther/Unknown/Declined -0.902 0.3688
## clean_sexMale 0.971 0.3335
## clean_sexNon-Binary -0.305 0.7609
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation matrix not shown by default, as p = 15 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
# Residuals vs. fitted values
hist(resid(t25fw_pws_multi_vid_adj), main = "Residuals All Video Metrics Adjusted")
# Normality check
qqnorm(residuals(t25fw_pws_multi_vid_adj), main = "Normal Q-Q plot: Residuals All Video Metrics Adjusted")
# tidy results
t25fw_pws_multi_vid_adj_df <- tidy(t25fw_pws_multi_vid_adj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(t25fw_pws_multi_vid_adj)$R2_conditional) %>%
mutate(R2_marginal = r2(t25fw_pws_multi_vid_adj)$R2_marginal) %>%
mutate(Model = "Adjusted - Multivariate Video Metrics")
t25fw_pws_multi_vid_adj_df
## # A tibble: 17 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inte~ 3.72e-1 0.0789 4.71 104. 7.57e-6 2.15e-1
## 2 fixed <NA> strid~ -4.76e-2 0.0336 -1.42 88.9 1.60e-1 -1.14e-1
## 3 fixed <NA> log_d~ 1.68e-2 0.00842 2.00 98.8 4.87e-2 1.00e-4
## 4 fixed <NA> mean_~ 2.97e-4 0.000399 0.744 93.5 4.59e-1 -4.96e-4
## 5 fixed <NA> strid~ -2.35e-3 0.00136 -1.72 146. 8.76e-2 -5.04e-3
## 6 fixed <NA> demoE~ -1.47e-3 0.000463 -3.18 110. 1.90e-3 -2.39e-3
## 7 fixed <NA> demoE~ -6.43e-5 0.000663 -0.0969 107. 9.23e-1 -1.38e-3
## 8 fixed <NA> ms_dx~ -3.06e-2 0.0148 -2.07 119. 4.05e-2 -5.98e-2
## 9 fixed <NA> ms_dx~ 6.44e-3 0.0381 0.169 122. 8.66e-1 -6.89e-2
## 10 fixed <NA> race_~ -3.32e-2 0.0196 -1.69 112. 9.34e-2 -7.22e-2
## 11 fixed <NA> race_~ -7.27e-2 0.0179 -4.06 104. 9.61e-5 -1.08e-1
## 12 fixed <NA> race_~ -1.70e-2 0.0158 -1.08 106. 2.85e-1 -4.83e-2
## 13 fixed <NA> race_~ -1.82e-2 0.0202 -0.902 115. 3.69e-1 -5.82e-2
## 14 fixed <NA> clean~ 1.04e-2 0.0107 0.971 112. 3.34e-1 -1.08e-2
## 15 fixed <NA> clean~ -1.61e-2 0.0527 -0.305 122. 7.61e-1 -1.20e-1
## 16 ran_pars bw_id sd__(~ 4.11e-2 NA NA NA NA NA
## 17 ran_pars Residual sd__O~ 3.16e-2 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
p value < 0.05, more complex model is significantly better than the simpler model
https://bookdown.org/ndphillips/YaRrr/comparing-regression-models-with-anova.html
# Demographics only vs Video + Demographics
anova(t25fw_pws_multi_dem, t25fw_pws_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: zeno_pws_clean_df
## Models:
## t25fw_pws_multi_dem: t25fw_inverse ~ demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## t25fw_pws_multi_vid_adj: t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## t25fw_pws_multi_dem 13 -491.71 -451.57 258.85 -517.71
## t25fw_pws_multi_vid_adj 17 -498.83 -446.34 266.42 -532.83 15.122 4
## Pr(>Chisq)
## t25fw_pws_multi_dem
## t25fw_pws_multi_vid_adj 0.004454 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Video only vs Video + Demographics
anova(t25fw_pws_multi_vid_unadj, t25fw_pws_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: zeno_pws_clean_df
## Models:
## t25fw_pws_multi_vid_unadj: t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + (1 | bw_id)
## t25fw_pws_multi_vid_adj: t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## t25fw_pws_multi_vid_unadj 7 -482.45 -460.84 248.22 -496.45
## t25fw_pws_multi_vid_adj 17 -498.83 -446.34 266.42 -532.83 36.381 10
## Pr(>Chisq)
## t25fw_pws_multi_vid_unadj
## t25fw_pws_multi_vid_adj 7.239e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t25fw_pws_multivar_all <- bind_rows(t25fw_pws_multi_dem_df,
t25fw_pws_multi_vid_unadj_df,
t25fw_pws_multi_vid_adj_df)
# save R-squared
adj_r_squared_df <- t25fw_pws_multivar_all[c('Model', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 3 x 3
## Model R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Unadjusted - Multivariate Demographics and MS Info 0.84 0.26
## 2 Unadjusted - Multivariate Video Metrics 0.73 0.15
## 3 Adjusted - Multivariate Video Metrics 0.76 0.35
write.csv(adj_r_squared_df, file.path(output_dir, 't25fw_inverse_adj_vs_unadj_pws_r2.csv'))
p <- adj_vs_unadj_plot(results_df = t25fw_pws_multivar_all,
plot_title = "PWS: Inverse T25FW Unadjusted vs Adjusted",
x_adj = 0.1)
p
ggsave(file.path(output_dir, 't25fw_inverse_adj_vs_unadj_pws_estimates.png'),
bg = "white", width= 12, height=10)
Outcome = Inverse Transform T25FW
uni_zv_fw_t25fw_inv <- all_univariate_mixed_effect(data = zeno_fw_df,
outcome_column = "t25fw_inverse")
## [1] "log_delta_pix_h_rel_median_pose"
## Warning: Removed 4 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ log_delta_pix_h_rel_median_pose + (1 | bw_id)
## <environment: 0x0000000030d46b78>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula1
## Data: data
##
## REML criterion at convergence: -666.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.1873 -0.4170 -0.0125 0.4484 3.1930
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.001521 0.03900
## Residual 0.001331 0.03648
## Number of obs: 218, groups: bw_id, 152
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.687e-01 7.860e-03 2.160e+02 34.192 <2e-16
## log_delta_pix_h_rel_median_pose 5.702e-02 6.285e-03 1.926e+02 9.071 <2e-16
##
## (Intercept) ***
## log_delta_pix_h_rel_median_pose ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## lg_dlt_____ 0.855
## [1] "stride_time_median_sec_pose"
## Warning: Removed 53 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ stride_time_median_sec_pose + (1 | bw_id)
## <environment: 0x0000000030d46b78>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula2
## Data: data
##
## REML criterion at convergence: -527.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.54287 -0.32608 -0.03509 0.34992 2.73440
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0022629 0.04757
## Residual 0.0007267 0.02696
## Number of obs: 169, groups: bw_id, 126
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.38706 0.02333 166.99441 16.59 < 2e-16 ***
## stride_time_median_sec_pose -0.18767 0.02391 166.62762 -7.85 4.81e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_tm_m__ -0.979
## [1] "mean_cadence_step_per_min_pose"
## Warning: Removed 46 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ mean_cadence_step_per_min_pose + (1 | bw_id)
## <environment: 0x0000000030d46b78>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula3
## Data: data
##
## REML criterion at convergence: -502.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.10312 -0.38242 -0.04459 0.30139 2.91658
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.002570 0.05070
## Residual 0.001031 0.03211
## Number of obs: 176, groups: bw_id, 129
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 9.623e-02 2.308e-02 1.545e+02 4.170 5.06e-05
## mean_cadence_step_per_min_pose 9.273e-04 1.891e-04 1.500e+02 4.903 2.42e-06
##
## (Intercept) ***
## mean_cadence_step_per_min_pose ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mn_cdnc____ -0.975
## [1] "stride_width_median_cm_pose"
## Warning: Removed 47 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ stride_width_median_cm_pose + (1 | bw_id)
## <environment: 0x0000000030d46b78>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula4
## Data: data
##
## REML criterion at convergence: -492.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7530 -0.3171 -0.0240 0.3067 2.3262
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0036487 0.06040
## Residual 0.0007272 0.02697
## Number of obs: 175, groups: bw_id, 128
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.235769 0.015987 108.428338 14.747 <2e-16
## stride_width_median_cm_pose -0.002414 0.001233 88.309028 -1.957 0.0535
##
## (Intercept) ***
## stride_width_median_cm_pose .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_wdt___ -0.933
## [1] "demoEHR_Age"
## t25fw_inverse ~ demoEHR_Age + (1 | bw_id)
## <environment: 0x0000000030d46b78>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula5
## Data: data
##
## REML criterion at convergence: -647.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.33199 -0.34903 -0.01902 0.32366 2.46221
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0032377 0.05690
## Residual 0.0007759 0.02785
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.921e-01 2.019e-02 1.543e+02 14.465 < 2e-16 ***
## demoEHR_Age -1.692e-03 3.896e-04 1.551e+02 -4.342 2.54e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## demoEHR_Age -0.969
## [1] "demoEHR_DiseaseDuration"
## t25fw_inverse ~ demoEHR_DiseaseDuration + (1 | bw_id)
## <environment: 0x0000000030d46b78>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula6
## Data: data
##
## REML criterion at convergence: -633.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.33333 -0.32325 -0.02284 0.28068 2.46155
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0036396 0.06033
## Residual 0.0007756 0.02785
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.177e-01 8.365e-03 1.561e+02 26.028 <2e-16 ***
## demoEHR_DiseaseDuration -1.095e-03 6.682e-04 1.580e+02 -1.638 0.103
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## dmEHR_DssDr -0.779
## [1] "ms_dx_condensed"
## t25fw_inverse ~ ms_dx_condensed + (1 | bw_id)
## <environment: 0x0000000030d46b78>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula7
## Data: data
##
## REML criterion at convergence: -669.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.35541 -0.35579 -0.01338 0.33543 2.49972
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0028261 0.05316
## Residual 0.0007631 0.02762
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.221930 0.005264 152.420568
## ms_dx_condensedProgressive MS -0.078609 0.012120 155.822998
## ms_dx_condensedMS, Subtype Not Specified -0.007644 0.042688 168.148599
## t value Pr(>|t|)
## (Intercept) 42.161 < 2e-16 ***
## ms_dx_condensedProgressive MS -6.486 1.11e-09 ***
## ms_dx_condensedMS, Subtype Not Specified -0.179 0.858
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) m__PMS
## ms_dx_cnPMS -0.434
## ms_d_MS,SNS -0.123 0.054
## [1] "race_ethnicity_clean"
## t25fw_inverse ~ race_ethnicity_clean + (1 | bw_id)
## <environment: 0x0000000030d46b78>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula8
## Data: data
##
## REML criterion at convergence: -627.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.3451 -0.3121 -0.0178 0.2820 2.4481
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0035736 0.05978
## Residual 0.0007762 0.02786
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.211444 0.006304 148.737325
## race_ethnicity_cleanAsian -0.023811 0.020423 147.275407
## race_ethnicity_cleanBlack Or African American -0.051771 0.020613 152.955864
## race_ethnicity_cleanHispanic or Latino 0.001897 0.017904 151.274717
## race_ethnicity_cleanOther/Unknown/Declined 0.010172 0.019672 148.312174
## t value Pr(>|t|)
## (Intercept) 33.542 <2e-16 ***
## race_ethnicity_cleanAsian -1.166 0.2455
## race_ethnicity_cleanBlack Or African American -2.512 0.0131 *
## race_ethnicity_cleanHispanic or Latino 0.106 0.9158
## race_ethnicity_cleanOther/Unknown/Declined 0.517 0.6059
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rc_t_A r__OAA r__HoL
## rc_thncty_A -0.309
## rc_thn_BOAA -0.306 0.094
## rc_thnc_HoL -0.352 0.109 0.108
## rc_th_O/U/D -0.320 0.099 0.098 0.113
## [1] "clean_sex"
## t25fw_inverse ~ clean_sex + (1 | bw_id)
## <environment: 0x0000000030d46b78>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula9
## Data: data
##
## REML criterion at convergence: -633.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.29045 -0.32315 -0.02408 0.28858 2.50979
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0037188 0.06098
## Residual 0.0007739 0.02782
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.039e-01 6.129e-03 1.513e+02 33.267 <2e-16 ***
## clean_sexMale 1.250e-02 1.232e-02 1.523e+02 1.015 0.312
## clean_sexNon-Binary 1.139e-02 6.437e-02 1.369e+02 0.177 0.860
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) cln_sM
## clean_sexMl -0.498
## cln_sxNn-Bn -0.095 0.047
# save adjusted r_squared
adj_r_squared_df <- uni_zv_fw_t25fw_inv[c('Variable', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 9 x 3
## Variable R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Log Pixel Height Proxy 0.65 0.25
## 2 Stride Time - Median 0.82 0.25
## 3 Cadence - Mean 0.74 0.1
## 4 Stride Width - Median 0.84 0.01
## 5 Age 0.83 0.1
## 6 Disease Duration 0.83 0.02
## 7 MS DX 0.83 0.2
## 8 Race and Ethnicity 0.83 0.05
## 9 Sex 0.83 0.01
write.csv(adj_r_squared_df, file.path(output_dir, 't25fw_inverse_univariate_fw_r2.csv'))
# Plot estimates
p <- univariate_regression_plot(results = uni_zv_fw_t25fw_inv,
plot_title = "FW Univariate - lmer(Inverse T25FW ~ Predictor + (1 | bw_id))",
x_adj = 0.1)
p
ggsave(file.path(output_dir, 't25fw_inverse_univariate_fw_estimates.png'),
bg = "white", width= 10, height=10)
Not all metrics could be calculated from each video metric
Dropped videos missing any video metric so models could be compared
zeno_fw_clean_df <- zeno_fw_df %>%
drop_na(c("stride_time_median_sec_pose_zv",
"log_delta_pix_h_rel_median_pose_zv",
"mean_cadence_step_per_min_pose_zv",
"stride_width_median_cm_pose_zv"))
colSums(is.na(zeno_fw_clean_df))
## X
## 0
## video_id_date_name_pose_zv
## 0
## id_date_pose_zv
## 0
## task_pose_zv
## 0
## frames_per_second_pose_zv
## 0
## total_video_duration_sec_pose_zv
## 0
## delta_pix_h_rel_median_pose_zv
## 0
## walking_segmets_n_pose_zv
## 0
## walking_segments_duration_mean_pose_zv
## 0
## walking_segments_duration_median_pose_zv
## 0
## stride_time_mean_sec_pose_zv
## 0
## stride_time_median_sec_pose_zv
## 0
## stride_time_std_pose_zv
## 1
## stride_time_cv_pose_zv
## 1
## stride_time_max_pose_zv
## 0
## stride_time_min_pose_zv
## 0
## mean_cadence_step_per_min_pose_zv
## 0
## stride_width_mean_cm_pose_zv
## 0
## stride_width_median_cm_pose_zv
## 0
## stride_width_std_pose_zv
## 1
## stride_width_cv_pose_zv
## 1
## stride_width_max_pose_zv
## 0
## stride_width_min_pose_zv
## 0
## foot1_gait_cycle_time_mean_pose_zv
## 134
## foot1_stance_time_mean_pose_zv
## 134
## foot1_stance_per_mean_pose_zv
## 134
## foot1_swing_time_mean_pose_zv
## 134
## foot1_swing_per_mean_pose_zv
## 134
## foot1_ini_double_support_time_mean_pose_zv
## 134
## foot1_term_double_support_time_mean_pose_zv
## 134
## foot1_tot_double_support_time_mean_pose_zv
## 134
## foot1_double_support_per_mean_pose_zv
## 134
## foot1_single_support_time_mean_pose_zv
## 134
## foot1_single_support_per_mean_pose_zv
## 134
## walk_segment_pose_zv
## 134
## foot1_pose_zv
## 0
## id_video
## 0
## visit_date_video
## 0
## bw_id
## 0
## trialdate
## 0
## visit_date
## 0
## demoEHR_DiseaseDuration
## 0
## clean_sex
## 0
## clean_race
## 0
## clean_ethnicity
## 0
## demoEHR_Age
## 0
## bingoEHR_DX_MS.DX
## 0
## bingoEHR_EDSS_measure_value
## 0
## msfcEHR_T25FW.SPEED.AVG
## 0
## FW_cadencestepsminmean
## 0
## FW_singlesupportmean
## 0
## FW_singlesupportratiolr
## 0
## FW_stridetimeseccv
## 0
## FW_stridetimesecmean
## 0
## FW_stridewidthcmmean
## 0
## FW_stridewidthcmsd
## 0
## FW_totaldsupportmean
## 0
## FW_totaldsupportratiolr
## 0
## FW_velocitycmsecmean
## 0
## PWS_cadencestepsminmean
## 0
## PWS_singlesupportmean
## 0
## PWS_singlesupportratiolr
## 0
## PWS_stridetimeseccv
## 0
## PWS_stridetimesecmean
## 0
## PWS_stridewidthcmmean
## 0
## PWS_stridewidthcmsd
## 0
## PWS_totaldsupportmean
## 0
## PWS_totaldsupportratiolr
## 0
## PWS_velocitycmsecmean
## 0
## redcap_event_name
## 0
## demographic_diagnosis
## 0
## bingoEHR_Vitals_height.in.
## 10
## bingoEHR_first_MS.DX
## 0
## edss_severity_num
## 0
## edss_severity_cat
## 0
## t25fw_group_num
## 0
## t25fw_group_cat
## 0
## race_ethnicity_clean
## 0
## ms_dx_condensed
## 0
## t25fw_log
## 0
## t25fw_inverse
## 0
##
## 0
## log_delta_pix_h_rel_median_pose_zv
## 0
t25fw_fw_multi_dem <- lmer(t25fw_inverse ~
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = zeno_fw_clean_df)
summary(t25fw_fw_multi_dem)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## t25fw_inverse ~ demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: zeno_fw_clean_df
##
## REML criterion at convergence: -453.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.5748 -0.3574 -0.0063 0.3115 2.5189
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0025301 0.05030
## Residual 0.0007046 0.02654
## Number of obs: 167, groups: bw_id, 125
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 3.002e-01 2.477e-02 1.186e+02
## demoEHR_Age -1.497e-03 4.905e-04 1.208e+02
## demoEHR_DiseaseDuration 1.761e-04 7.341e-04 1.185e+02
## ms_dx_condensedProgressive MS -6.413e-02 1.452e-02 1.185e+02
## ms_dx_condensedMS, Subtype Not Specified -3.678e-02 5.931e-02 1.239e+02
## race_ethnicity_cleanAsian -4.925e-02 1.952e-02 1.164e+02
## race_ethnicity_cleanBlack Or African American -7.915e-02 1.973e-02 1.151e+02
## race_ethnicity_cleanHispanic or Latino -1.727e-02 1.774e-02 1.156e+02
## race_ethnicity_cleanOther/Unknown/Declined -7.756e-03 2.011e-02 1.179e+02
## clean_sexMale 1.051e-02 1.192e-02 1.156e+02
## clean_sexNon-Binary -1.608e-02 5.469e-02 9.961e+01
## t value Pr(>|t|)
## (Intercept) 12.120 < 2e-16 ***
## demoEHR_Age -3.052 0.002794 **
## demoEHR_DiseaseDuration 0.240 0.810858
## ms_dx_condensedProgressive MS -4.417 2.22e-05 ***
## ms_dx_condensedMS, Subtype Not Specified -0.620 0.536320
## race_ethnicity_cleanAsian -2.523 0.012984 *
## race_ethnicity_cleanBlack Or African American -4.013 0.000107 ***
## race_ethnicity_cleanHispanic or Latino -0.974 0.332201
## race_ethnicity_cleanOther/Unknown/Declined -0.386 0.700445
## clean_sexMale 0.882 0.379808
## clean_sexNon-Binary -0.294 0.769392
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) dEHR_A dEHR_D m__PMS m__SNS rc_t_A r__OAA r__HoL r__O/U
## demoEHR_Age -0.907
## dmEHR_DssDr 0.091 -0.401
## ms_dx_cnPMS 0.150 -0.213 -0.102
## ms_d_MS,SNS 0.097 -0.053 -0.169 0.095
## rc_thncty_A -0.338 0.234 0.040 -0.015 -0.003
## rc_thn_BOAA -0.183 0.087 0.017 0.028 0.015 0.130
## rc_thnc_HoL -0.275 0.201 -0.025 -0.040 0.030 0.169 0.127
## rc_th_O/U/D -0.382 0.254 0.028 0.045 -0.028 0.182 0.138 0.152
## clean_sexMl -0.219 0.082 0.033 -0.021 -0.166 0.003 0.037 -0.088 0.183
## cln_sxNn-Bn -0.079 -0.002 0.125 0.020 -0.022 0.057 0.047 0.042 0.068
## cln_sM
## demoEHR_Age
## dmEHR_DssDr
## ms_dx_cnPMS
## ms_d_MS,SNS
## rc_thncty_A
## rc_thn_BOAA
## rc_thnc_HoL
## rc_th_O/U/D
## clean_sexMl
## cln_sxNn-Bn 0.065
# Residuals vs. fitted values
hist(resid(t25fw_fw_multi_dem), main = "Residuals All Demographic and MS Info")
# Normality check
qqnorm(residuals(t25fw_fw_multi_dem), main = "Normal Q-Q plot: Residuals All Demographic and MS Info")
# tidy results
t25fw_fw_multi_dem_df <- tidy(t25fw_fw_multi_dem, conf.int = TRUE) %>%
mutate(R2_conditional = r2(t25fw_fw_multi_dem)$R2_conditional) %>%
mutate(R2_marginal = r2(t25fw_fw_multi_dem)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Demographics and MS Info")
t25fw_fw_multi_dem_df
## # A tibble: 13 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Int~ 3.00e-1 0.0248 12.1 119. 1.72e-22 0.251
## 2 fixed <NA> demo~ -1.50e-3 0.000491 -3.05 121. 2.79e- 3 -0.00247
## 3 fixed <NA> demo~ 1.76e-4 0.000734 0.240 119. 8.11e- 1 -0.00128
## 4 fixed <NA> ms_d~ -6.41e-2 0.0145 -4.42 119. 2.22e- 5 -0.0929
## 5 fixed <NA> ms_d~ -3.68e-2 0.0593 -0.620 124. 5.36e- 1 -0.154
## 6 fixed <NA> race~ -4.92e-2 0.0195 -2.52 116. 1.30e- 2 -0.0879
## 7 fixed <NA> race~ -7.91e-2 0.0197 -4.01 115. 1.07e- 4 -0.118
## 8 fixed <NA> race~ -1.73e-2 0.0177 -0.974 116. 3.32e- 1 -0.0524
## 9 fixed <NA> race~ -7.76e-3 0.0201 -0.386 118. 7.00e- 1 -0.0476
## 10 fixed <NA> clea~ 1.05e-2 0.0119 0.882 116. 3.80e- 1 -0.0131
## 11 fixed <NA> clea~ -1.61e-2 0.0547 -0.294 99.6 7.69e- 1 -0.125
## 12 ran_pars bw_id sd__~ 5.03e-2 NA NA NA NA NA
## 13 ran_pars Residual sd__~ 2.65e-2 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
t25fw_fw_multi_vid_unadj <- lmer(t25fw_inverse ~
stride_time_median_sec_pose_zv +
log_delta_pix_h_rel_median_pose_zv +
mean_cadence_step_per_min_pose_zv +
stride_width_median_cm_pose_zv +
(1|bw_id),
data = zeno_fw_clean_df)
summary(t25fw_fw_multi_vid_unadj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv +
## mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv +
## (1 | bw_id)
## Data: zeno_fw_clean_df
##
## REML criterion at convergence: -508.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0880 -0.4273 -0.0690 0.5028 3.3493
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.001364 0.03693
## Residual 0.001011 0.03180
## Number of obs: 167, groups: bw_id, 125
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 3.322e-01 5.949e-02 1.423e+02 5.584
## stride_time_median_sec_pose_zv -1.183e-01 3.255e-02 1.510e+02 -3.634
## log_delta_pix_h_rel_median_pose_zv 3.498e-02 7.595e-03 1.039e+02 4.605
## mean_cadence_step_per_min_pose_zv 3.545e-04 2.688e-04 1.244e+02 1.319
## stride_width_median_cm_pose_zv -1.367e-03 1.301e-03 1.241e+02 -1.050
## Pr(>|t|)
## (Intercept) 1.16e-07 ***
## stride_time_median_sec_pose_zv 0.000383 ***
## log_delta_pix_h_rel_median_pose_zv 1.17e-05 ***
## mean_cadence_step_per_min_pose_zv 0.189654
## stride_width_median_cm_pose_zv 0.295545
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) strd_t____ l_____ m_____
## strd_tm____ -0.838
## lg_dl______ -0.016 0.278
## mn_cdn_____ -0.897 0.634 -0.101
## strd_wd____ -0.262 0.031 0.233 0.022
# Residuals vs. fitted values
hist(resid(t25fw_fw_multi_vid_unadj), main = "Residuals All Video Metrics Unadjusted")
# Normality check
qqnorm(residuals(t25fw_fw_multi_vid_unadj), main = "Normal Q-Q plot: Residuals All Video Metrics Unadjusted")
# tidy results
t25fw_fw_multi_vid_unadj_df <- tidy(t25fw_fw_multi_vid_unadj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(t25fw_fw_multi_vid_unadj)$R2_conditional) %>%
mutate(R2_marginal = r2(t25fw_fw_multi_vid_unadj)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Video Metrics")
t25fw_fw_multi_vid_unadj_df
## # A tibble: 7 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inter~ 3.32e-1 0.0595 5.58 142. 1.16e-7 2.15e-1
## 2 fixed <NA> stride~ -1.18e-1 0.0325 -3.63 151. 3.83e-4 -1.83e-1
## 3 fixed <NA> log_de~ 3.50e-2 0.00760 4.61 104. 1.17e-5 1.99e-2
## 4 fixed <NA> mean_c~ 3.55e-4 0.000269 1.32 124. 1.90e-1 -1.78e-4
## 5 fixed <NA> stride~ -1.37e-3 0.00130 -1.05 124. 2.96e-1 -3.94e-3
## 6 ran_pars bw_id sd__(I~ 3.69e-2 NA NA NA NA NA
## 7 ran_pars Residual sd__Ob~ 3.18e-2 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
t25fw_fw_multi_vid_adj <- lmer(t25fw_inverse ~
stride_time_median_sec_pose_zv +
log_delta_pix_h_rel_median_pose_zv +
mean_cadence_step_per_min_pose_zv +
stride_width_median_cm_pose_zv +
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = zeno_fw_clean_df)
summary(t25fw_fw_multi_vid_adj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv +
## mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv +
## demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: zeno_fw_clean_df
##
## REML criterion at convergence: -470.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9018 -0.4440 -0.0223 0.4637 3.4383
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0010421 0.03228
## Residual 0.0009064 0.03011
## Number of obs: 167, groups: bw_id, 125
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 3.772e-01 5.868e-02 1.470e+02
## stride_time_median_sec_pose_zv -1.035e-01 3.078e-02 1.484e+02
## log_delta_pix_h_rel_median_pose_zv 2.963e-02 7.286e-03 1.051e+02
## mean_cadence_step_per_min_pose_zv 4.035e-04 2.547e-04 1.272e+02
## stride_width_median_cm_pose_zv -3.059e-04 1.264e-03 1.208e+02
## demoEHR_Age -1.429e-03 3.773e-04 1.132e+02
## demoEHR_DiseaseDuration -2.995e-04 5.670e-04 9.727e+01
## ms_dx_condensedProgressive MS -1.332e-02 1.247e-02 1.086e+02
## ms_dx_condensedMS, Subtype Not Specified -4.429e-02 4.607e-02 1.240e+02
## race_ethnicity_cleanAsian -3.647e-02 1.504e-02 1.040e+02
## race_ethnicity_cleanBlack Or African American -5.929e-02 1.524e-02 1.034e+02
## race_ethnicity_cleanHispanic or Latino -1.321e-02 1.370e-02 1.036e+02
## race_ethnicity_cleanOther/Unknown/Declined -7.381e-03 1.539e-02 1.084e+02
## clean_sexMale 1.135e-02 9.166e-03 1.033e+02
## clean_sexNon-Binary -2.436e-02 3.959e-02 6.546e+01
## t value Pr(>|t|)
## (Intercept) 6.428 1.70e-09 ***
## stride_time_median_sec_pose_zv -3.364 0.000978 ***
## log_delta_pix_h_rel_median_pose_zv 4.066 9.25e-05 ***
## mean_cadence_step_per_min_pose_zv 1.584 0.115683
## stride_width_median_cm_pose_zv -0.242 0.809217
## demoEHR_Age -3.786 0.000247 ***
## demoEHR_DiseaseDuration -0.528 0.598536
## ms_dx_condensedProgressive MS -1.068 0.287934
## ms_dx_condensedMS, Subtype Not Specified -0.961 0.338201
## race_ethnicity_cleanAsian -2.425 0.017015 *
## race_ethnicity_cleanBlack Or African American -3.890 0.000177 ***
## race_ethnicity_cleanHispanic or Latino -0.964 0.337132
## race_ethnicity_cleanOther/Unknown/Declined -0.479 0.632561
## clean_sexMale 1.238 0.218344
## clean_sexNon-Binary -0.615 0.540458
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation matrix not shown by default, as p = 15 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
# Residuals vs. fitted values
hist(resid(t25fw_fw_multi_vid_adj), main = "Residuals All Video Metrics Adjusted")
# Normality check
qqnorm(residuals(t25fw_fw_multi_vid_adj), main = "Normal Q-Q plot: Residuals All Video Metrics Adjusted")
# tidy results
t25fw_fw_multi_vid_adj_df <- tidy(t25fw_fw_multi_vid_adj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(t25fw_fw_multi_vid_adj)$R2_conditional) %>%
mutate(R2_marginal = r2(t25fw_fw_multi_vid_adj)$R2_marginal) %>%
mutate(Model = "Adjusted - Multivariate Video Metrics")
t25fw_fw_multi_vid_adj_df
## # A tibble: 17 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inte~ 3.77e-1 0.0587 6.43 147. 1.70e-9 2.61e-1
## 2 fixed <NA> strid~ -1.04e-1 0.0308 -3.36 148. 9.78e-4 -1.64e-1
## 3 fixed <NA> log_d~ 2.96e-2 0.00729 4.07 105. 9.25e-5 1.52e-2
## 4 fixed <NA> mean_~ 4.03e-4 0.000255 1.58 127. 1.16e-1 -1.01e-4
## 5 fixed <NA> strid~ -3.06e-4 0.00126 -0.242 121. 8.09e-1 -2.81e-3
## 6 fixed <NA> demoE~ -1.43e-3 0.000377 -3.79 113. 2.47e-4 -2.18e-3
## 7 fixed <NA> demoE~ -3.00e-4 0.000567 -0.528 97.3 5.99e-1 -1.42e-3
## 8 fixed <NA> ms_dx~ -1.33e-2 0.0125 -1.07 109. 2.88e-1 -3.80e-2
## 9 fixed <NA> ms_dx~ -4.43e-2 0.0461 -0.961 124. 3.38e-1 -1.35e-1
## 10 fixed <NA> race_~ -3.65e-2 0.0150 -2.43 104. 1.70e-2 -6.63e-2
## 11 fixed <NA> race_~ -5.93e-2 0.0152 -3.89 103. 1.77e-4 -8.95e-2
## 12 fixed <NA> race_~ -1.32e-2 0.0137 -0.964 104. 3.37e-1 -4.04e-2
## 13 fixed <NA> race_~ -7.38e-3 0.0154 -0.479 108. 6.33e-1 -3.79e-2
## 14 fixed <NA> clean~ 1.14e-2 0.00917 1.24 103. 2.18e-1 -6.83e-3
## 15 fixed <NA> clean~ -2.44e-2 0.0396 -0.615 65.5 5.40e-1 -1.03e-1
## 16 ran_pars bw_id sd__(~ 3.23e-2 NA NA NA NA NA
## 17 ran_pars Residual sd__O~ 3.01e-2 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
p value < 0.05, more complex model is significantly better than the simpler model
https://bookdown.org/ndphillips/YaRrr/comparing-regression-models-with-anova.html
# Demographics only vs Video + Demographics
anova(t25fw_fw_multi_dem, t25fw_fw_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: zeno_fw_clean_df
## Models:
## t25fw_fw_multi_dem: t25fw_inverse ~ demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## t25fw_fw_multi_vid_adj: t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## t25fw_fw_multi_dem 13 -509.29 -468.76 267.65 -535.29
## t25fw_fw_multi_vid_adj 17 -564.54 -511.53 299.27 -598.54 63.242 4
## Pr(>Chisq)
## t25fw_fw_multi_dem
## t25fw_fw_multi_vid_adj 6.035e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Video only vs Video + Demographics
anova(t25fw_fw_multi_vid_unadj, t25fw_fw_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: zeno_fw_clean_df
## Models:
## t25fw_fw_multi_vid_unadj: t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + (1 | bw_id)
## t25fw_fw_multi_vid_adj: t25fw_inverse ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## t25fw_fw_multi_vid_unadj 7 -543.38 -521.56 278.69 -557.38
## t25fw_fw_multi_vid_adj 17 -564.54 -511.53 299.27 -598.54 41.154 10
## Pr(>Chisq)
## t25fw_fw_multi_vid_unadj
## t25fw_fw_multi_vid_adj 1.06e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t25fw_fw_multivar_all <- bind_rows(t25fw_fw_multi_dem_df,
t25fw_fw_multi_vid_unadj_df,
t25fw_fw_multi_vid_adj_df)
# save R-squared
adj_r_squared_df <- t25fw_fw_multivar_all[c('Model', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 3 x 3
## Model R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Unadjusted - Multivariate Demographics and MS Info 0.85 0.3
## 2 Unadjusted - Multivariate Video Metrics 0.74 0.4
## 3 Adjusted - Multivariate Video Metrics 0.79 0.55
write.csv(adj_r_squared_df, file.path(output_dir, 't25fw_inverse_adj_vs_unadj_fw_r2.csv'))
p <- adj_vs_unadj_plot(results_df = t25fw_fw_multivar_all,
plot_title = "FW: Inverse T25FW Unadjusted vs Adjusted",
x_adj = 0.1)
p
ggsave(file.path(output_dir, 't25fw_inverse_adj_vs_unadj_FW_estimates.png'),
bg = "white", width= 12, height=10)
Outcome = Inverse Transform T25FW
uni_hv_t25fw_inv <- all_univariate_mixed_effect(data = home_df,
outcome_column = "t25fw_inverse")
## [1] "log_delta_pix_h_rel_median_pose"
## Warning: Removed 4 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ log_delta_pix_h_rel_median_pose + (1 | bw_id)
## <environment: 0x0000000033685d70>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula1
## Data: data
##
## REML criterion at convergence: -222
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.20740 -0.17872 -0.01406 0.19732 2.22353
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0037644 0.06135
## Residual 0.0002276 0.01509
## Number of obs: 61, groups: bw_id, 30
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.222288 0.016966 57.894807 13.102 <2e-16
## log_delta_pix_h_rel_median_pose 0.016957 0.009155 42.952256 1.852 0.0709
##
## (Intercept) ***
## log_delta_pix_h_rel_median_pose .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## lg_dlt_____ 0.741
## [1] "stride_time_median_sec_pose"
## Warning: Removed 13 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ stride_time_median_sec_pose + (1 | bw_id)
## <environment: 0x0000000033685d70>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula2
## Data: data
##
## REML criterion at convergence: -190.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.05158 -0.13872 -0.02463 0.13797 2.15674
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.004071 0.06380
## Residual 0.000259 0.01609
## Number of obs: 52, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.21665 0.04428 49.21227 4.893 1.11e-05 ***
## stride_time_median_sec_pose -0.01337 0.03531 49.99306 -0.379 0.707
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_tm_m__ -0.952
## [1] "mean_cadence_step_per_min_pose"
## Warning: Removed 12 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ mean_cadence_step_per_min_pose + (1 | bw_id)
## <environment: 0x0000000033685d70>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula3
## Data: data
##
## REML criterion at convergence: -186.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.09674 -0.14982 -0.04066 0.12612 2.23609
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0041095 0.06411
## Residual 0.0002448 0.01565
## Number of obs: 53, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.849e-01 2.458e-02 4.931e+01 7.525 9.86e-10
## mean_cadence_step_per_min_pose 1.539e-04 1.991e-04 3.175e+01 0.773 0.445
##
## (Intercept) ***
## mean_cadence_step_per_min_pose
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mn_cdnc____ -0.834
## [1] "stride_width_median_cm_pose"
## Warning: Removed 12 rows containing missing values (`geom_point()`).
## t25fw_inverse ~ stride_width_median_cm_pose + (1 | bw_id)
## <environment: 0x0000000033685d70>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula4
## Data: data
##
## REML criterion at convergence: -193
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.36921 -0.18866 0.00824 0.18918 2.19279
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0037315 0.06109
## Residual 0.0002433 0.01560
## Number of obs: 53, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.233644 0.022924 50.290046 10.192 7.9e-14 ***
## stride_width_median_cm_pose -0.002488 0.001433 32.908115 -1.736 0.0919 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_wdt___ -0.826
## [1] "demoEHR_Age"
## t25fw_inverse ~ demoEHR_Age + (1 | bw_id)
## <environment: 0x0000000033685d70>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula5
## Data: data
##
## REML criterion at convergence: -241.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.28072 -0.07812 -0.00165 0.10099 2.35700
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0033466 0.05785
## Residual 0.0002077 0.01441
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.3100175 0.0449534 28.8346954 6.896 1.45e-07 ***
## demoEHR_Age -0.0021324 0.0008394 28.8471630 -2.540 0.0167 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## demoEHR_Age -0.972
## [1] "demoEHR_DiseaseDuration"
## t25fw_inverse ~ demoEHR_DiseaseDuration + (1 | bw_id)
## <environment: 0x0000000033685d70>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula6
## Data: data
##
## REML criterion at convergence: -238.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.16953 -0.10488 -0.00581 0.09556 2.32969
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0037911 0.06157
## Residual 0.0002057 0.01434
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.224684 0.019091 29.854249 11.769 9.69e-13 ***
## demoEHR_DiseaseDuration -0.002317 0.001394 30.126294 -1.661 0.107
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## dmEHR_DssDr -0.809
## [1] "ms_dx_condensed"
## t25fw_inverse ~ ms_dx_condensed + (1 | bw_id)
## <environment: 0x0000000033685d70>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula7
## Data: data
##
## REML criterion at convergence: -245.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.26388 -0.10870 -0.00785 0.12494 2.36993
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0032602 0.05710
## Residual 0.0002081 0.01443
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 0.211994 0.011854 27.885494 17.884
## ms_dx_condensedProgressive MS -0.081647 0.028591 28.055887 -2.856
## ms_dx_condensedMS, Subtype Not Specified 0.002292 0.042693 27.772130 0.054
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## ms_dx_condensedProgressive MS 0.00799 **
## ms_dx_condensedMS, Subtype Not Specified 0.95757
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) m__PMS
## ms_dx_cnPMS -0.415
## ms_d_MS,SNS -0.278 0.115
## [1] "race_ethnicity_clean"
## t25fw_inverse ~ race_ethnicity_clean + (1 | bw_id)
## <environment: 0x0000000033685d70>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula8
## Data: data
##
## REML criterion at convergence: -238.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.30639 -0.09202 0.00000 0.10448 2.33295
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0035069 0.05922
## Residual 0.0002076 0.01441
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.19764 0.01229 26.09424
## race_ethnicity_cleanAsian 0.03139 0.04423 25.93546
## race_ethnicity_cleanBlack Or African American -0.13353 0.06133 25.92911
## race_ethnicity_cleanHispanic or Latino -0.03635 0.06133 25.92911
## race_ethnicity_cleanOther/Unknown/Declined 0.04994 0.03680 25.90407
## t value Pr(>|t|)
## (Intercept) 16.085 4.63e-15 ***
## race_ethnicity_cleanAsian 0.710 0.4842
## race_ethnicity_cleanBlack Or African American -2.177 0.0388 *
## race_ethnicity_cleanHispanic or Latino -0.593 0.5586
## race_ethnicity_cleanOther/Unknown/Declined 1.357 0.1865
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rc_t_A r__OAA r__HoL
## rc_thncty_A -0.278
## rc_thn_BOAA -0.200 0.056
## rc_thnc_HoL -0.200 0.056 0.040
## rc_th_O/U/D -0.334 0.093 0.067 0.067
## [1] "clean_sex"
## t25fw_inverse ~ clean_sex + (1 | bw_id)
## <environment: 0x0000000033685d70>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula9
## Data: data
##
## REML criterion at convergence: -240.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.25613 -0.09814 -0.00234 0.07580 2.38367
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0039414 0.06278
## Residual 0.0002076 0.01441
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.18999 0.01300 28.06524 14.620 1.19e-14 ***
## clean_sexMale 0.04369 0.02908 28.16454 1.502 0.144
## clean_sexNon-Binary 0.01834 0.06492 27.96449 0.283 0.780
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) cln_sM
## clean_sexMl -0.447
## cln_sxNn-Bn -0.200 0.089
# save adjusted r_squared
adj_r_squared_df <- uni_hv_t25fw_inv[c('Variable', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 9 x 3
## Variable R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Log Pixel Height Proxy 0.94 0.02
## 2 Stride Time - Median 0.94 0
## 3 Cadence - Mean 0.94 0
## 4 Stride Width - Median 0.94 0.01
## 5 Age 0.95 0.18
## 6 Disease Duration 0.95 0.08
## 7 MS DX 0.95 0.19
## 8 Race and Ethnicity 0.96 0.21
## 9 Sex 0.95 0.06
write.csv(adj_r_squared_df, file.path(output_dir, 't25fw_inverse_univariate_home_r2.csv'))
# Plot estimates
p <- univariate_regression_plot(results = uni_hv_t25fw_inv,
plot_title = "Home Univariate - lmer(Inverse T25FW ~ Predictor + (1 | bw_id))",
x_adj = 0.1)
p
ggsave(file.path(output_dir, 't25fw_inverse_univariate_home_estimates.png'),
bg = "white", width= 10, height=10)
Not all metrics could be calculated from each video metric
Dropped videos missing any video metric so models could be compared
home_clean_df <- home_df %>%
drop_na(c("stride_time_median_sec_pose_hv",
"log_delta_pix_h_rel_median_pose_hv",
"mean_cadence_step_per_min_pose_hv",
"stride_width_median_cm_pose_hv"))
colSums(is.na(home_clean_df))
## X
## 0
## video_id_date_name_pose_hv
## 0
## id_date_pose_hv
## 0
## task_pose_hv
## 0
## frames_per_second_pose_hv
## 0
## total_video_duration_sec_pose_hv
## 0
## delta_pix_h_rel_median_pose_hv
## 0
## walking_segmets_n_pose_hv
## 0
## walking_segments_duration_mean_pose_hv
## 0
## walking_segments_duration_median_pose_hv
## 0
## stride_time_mean_sec_pose_hv
## 0
## stride_time_median_sec_pose_hv
## 0
## stride_time_std_pose_hv
## 1
## stride_time_cv_pose_hv
## 1
## stride_time_max_pose_hv
## 0
## stride_time_min_pose_hv
## 0
## mean_cadence_step_per_min_pose_hv
## 0
## stride_width_mean_cm_pose_hv
## 0
## stride_width_median_cm_pose_hv
## 0
## stride_width_std_pose_hv
## 0
## stride_width_cv_pose_hv
## 0
## stride_width_max_pose_hv
## 0
## stride_width_min_pose_hv
## 0
## foot1_gait_cycle_time_mean_pose_hv
## 21
## foot1_stance_time_mean_pose_hv
## 21
## foot1_stance_per_mean_pose_hv
## 21
## foot1_swing_time_mean_pose_hv
## 21
## foot1_swing_per_mean_pose_hv
## 21
## foot1_ini_double_support_time_mean_pose_hv
## 21
## foot1_term_double_support_time_mean_pose_hv
## 21
## foot1_tot_double_support_time_mean_pose_hv
## 21
## foot1_double_support_per_mean_pose_hv
## 21
## foot1_single_support_time_mean_pose_hv
## 21
## foot1_single_support_per_mean_pose_hv
## 21
## walk_segment_pose_hv
## 21
## foot1_pose_hv
## 0
## id_video
## 0
## visit_date_video
## 0
## bw_id
## 0
## trialdate
## 0
## visit_date
## 0
## demoEHR_DiseaseDuration
## 0
## clean_sex
## 0
## clean_race
## 0
## clean_ethnicity
## 0
## demoEHR_Age
## 0
## bingoEHR_DX_MS.DX
## 0
## bingoEHR_EDSS_measure_value
## 0
## msfcEHR_T25FW.SPEED.AVG
## 0
## FW_cadencestepsminmean
## 0
## FW_singlesupportmean
## 0
## FW_singlesupportratiolr
## 0
## FW_stridetimeseccv
## 0
## FW_stridetimesecmean
## 0
## FW_stridewidthcmmean
## 0
## FW_stridewidthcmsd
## 0
## FW_totaldsupportmean
## 0
## FW_totaldsupportratiolr
## 0
## FW_velocitycmsecmean
## 0
## PWS_cadencestepsminmean
## 0
## PWS_singlesupportmean
## 0
## PWS_singlesupportratiolr
## 0
## PWS_stridetimeseccv
## 0
## PWS_stridetimesecmean
## 0
## PWS_stridewidthcmmean
## 0
## PWS_stridewidthcmsd
## 0
## PWS_totaldsupportmean
## 0
## PWS_totaldsupportratiolr
## 0
## PWS_velocitycmsecmean
## 0
## redcap_event_name
## 0
## demographic_diagnosis
## 0
## bingoEHR_Vitals_height.in.
## 4
## bingoEHR_first_MS.DX
## 0
## edss_severity_num
## 0
## edss_severity_cat
## 0
## t25fw_group_num
## 0
## t25fw_group_cat
## 0
## race_ethnicity_clean
## 0
## ms_dx_condensed
## 0
## bw_hv_abs_date_diff
## 0
## t25fw_log
## 0
## t25fw_inverse
## 0
##
## 0
## log_delta_pix_h_rel_median_pose_hv
## 0
t25fw_home_multi_dem <- lmer(t25fw_inverse ~
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = home_clean_df)
summary(t25fw_home_multi_dem)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## t25fw_inverse ~ demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: home_clean_df
##
## REML criterion at convergence: -164.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0084 -0.1560 0.0000 0.1933 2.1302
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.001546 0.03932
## Residual 0.000251 0.01584
## Number of obs: 51, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.2508142 0.0477598 13.8806002
## demoEHR_Age -0.0007275 0.0009284 14.1597856
## demoEHR_DiseaseDuration -0.0012726 0.0013736 14.7217691
## ms_dx_condensedProgressive MS -0.1011598 0.0243464 14.0431223
## ms_dx_condensedMS, Subtype Not Specified 0.0096999 0.0353248 14.0674519
## race_ethnicity_cleanAsian 0.0731286 0.0460612 13.9157408
## race_ethnicity_cleanHispanic or Latino -0.0069675 0.0477163 14.0560319
## race_ethnicity_cleanOther/Unknown/Declined 0.0416148 0.0305952 14.1273505
## clean_sexMale 0.0515676 0.0243978 14.4804702
## t value Pr(>|t|)
## (Intercept) 5.252 0.000126 ***
## demoEHR_Age -0.784 0.446169
## demoEHR_DiseaseDuration -0.926 0.369161
## ms_dx_condensedProgressive MS -4.155 0.000966 ***
## ms_dx_condensedMS, Subtype Not Specified 0.275 0.787621
## race_ethnicity_cleanAsian 1.588 0.134823
## race_ethnicity_cleanHispanic or Latino -0.146 0.885980
## race_ethnicity_cleanOther/Unknown/Declined 1.360 0.195085
## clean_sexMale 2.114 0.052348 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) dEHR_A dEHR_D m__PMS m__SNS rc_t_A r__HoL r__O/U
## demoEHR_Age -0.936
## dmEHR_DssDr 0.241 -0.470
## ms_dx_cnPMS 0.090 -0.188 -0.047
## ms_d_MS,SNS 0.308 -0.328 -0.103 0.270
## rc_thncty_A -0.424 0.341 -0.048 0.041 -0.082
## rc_thnc_HoL 0.056 -0.035 -0.369 0.194 0.204 0.010
## rc_th_O/U/D -0.522 0.461 -0.317 0.118 -0.017 0.263 0.149
## clean_sexMl -0.488 0.429 -0.260 -0.074 -0.264 0.243 0.116 0.364
# Residuals vs. fitted values
hist(resid(t25fw_home_multi_dem), main = "Residuals All Demographic and MS Info")
# Normality check
qqnorm(residuals(t25fw_home_multi_dem), main = "Normal Q-Q plot: Residuals All Demographic and MS Info")
# tidy results
t25fw_home_multi_dem_df <- tidy(t25fw_home_multi_dem, conf.int = TRUE) %>%
mutate(R2_conditional = r2(t25fw_home_multi_dem)$R2_conditional) %>%
mutate(R2_marginal = r2(t25fw_home_multi_dem)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Demographics and MS Info")
t25fw_home_multi_dem_df
## # A tibble: 11 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inte~ 2.51e-1 0.0478 5.25 13.9 1.26e-4 1.48e-1
## 2 fixed <NA> demoE~ -7.27e-4 0.000928 -0.784 14.2 4.46e-1 -2.72e-3
## 3 fixed <NA> demoE~ -1.27e-3 0.00137 -0.926 14.7 3.69e-1 -4.21e-3
## 4 fixed <NA> ms_dx~ -1.01e-1 0.0243 -4.16 14.0 9.66e-4 -1.53e-1
## 5 fixed <NA> ms_dx~ 9.70e-3 0.0353 0.275 14.1 7.88e-1 -6.60e-2
## 6 fixed <NA> race_~ 7.31e-2 0.0461 1.59 13.9 1.35e-1 -2.57e-2
## 7 fixed <NA> race_~ -6.97e-3 0.0477 -0.146 14.1 8.86e-1 -1.09e-1
## 8 fixed <NA> race_~ 4.16e-2 0.0306 1.36 14.1 1.95e-1 -2.39e-2
## 9 fixed <NA> clean~ 5.16e-2 0.0244 2.11 14.5 5.23e-2 -5.98e-4
## 10 ran_pars bw_id sd__(~ 3.93e-2 NA NA NA NA NA
## 11 ran_pars Residual sd__O~ 1.58e-2 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
t25fw_home_multi_vid_unadj <- lmer(t25fw_inverse ~
stride_time_median_sec_pose_hv +
log_delta_pix_h_rel_median_pose_hv +
mean_cadence_step_per_min_pose_hv +
stride_width_median_cm_pose_hv +
(1|bw_id),
data = home_clean_df)
summary(t25fw_home_multi_vid_unadj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## t25fw_inverse ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv +
## mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv +
## (1 | bw_id)
## Data: home_clean_df
##
## REML criterion at convergence: -158.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9388 -0.3147 -0.0122 0.3599 2.0351
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.0029432 0.05425
## Residual 0.0003085 0.01757
## Number of obs: 51, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 0.2477041 0.0648192 40.7298969 3.821
## stride_time_median_sec_pose_hv -0.0205564 0.0382025 45.9439266 -0.538
## log_delta_pix_h_rel_median_pose_hv 0.0150123 0.0154764 26.4420943 0.970
## mean_cadence_step_per_min_pose_hv 0.0002833 0.0002729 22.0126866 1.038
## stride_width_median_cm_pose_hv -0.0025538 0.0019784 30.4994112 -1.291
## Pr(>|t|)
## (Intercept) 0.000445 ***
## stride_time_median_sec_pose_hv 0.593113
## log_delta_pix_h_rel_median_pose_hv 0.340830
## mean_cadence_step_per_min_pose_hv 0.310395
## stride_width_median_cm_pose_hv 0.206445
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) strd_t____ l_____ m_____
## strd_tm____ -0.819
## lg_dl______ -0.110 0.308
## mn_cdn_____ -0.629 0.282 -0.076
## strd_wd____ -0.361 0.197 0.526 -0.076
# Residuals vs. fitted values
hist(resid(t25fw_home_multi_vid_unadj), main = "Residuals All Video Metrics Unadjusted")
# Normality check
qqnorm(residuals(t25fw_home_multi_vid_unadj), main = "Normal Q-Q plot: Residuals All Video Metrics Unadjusted")
# tidy results
t25fw_home_multi_vid_unadj_df <- tidy(t25fw_home_multi_vid_unadj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(t25fw_home_multi_vid_unadj)$R2_conditional) %>%
mutate(R2_marginal = r2(t25fw_home_multi_vid_unadj)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Video Metrics")
t25fw_home_multi_vid_unadj_df
## # A tibble: 7 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inter~ 2.48e-1 0.0648 3.82 40.7 4.45e-4 1.17e-1
## 2 fixed <NA> stride~ -2.06e-2 0.0382 -0.538 45.9 5.93e-1 -9.75e-2
## 3 fixed <NA> log_de~ 1.50e-2 0.0155 0.970 26.4 3.41e-1 -1.68e-2
## 4 fixed <NA> mean_c~ 2.83e-4 0.000273 1.04 22.0 3.10e-1 -2.83e-4
## 5 fixed <NA> stride~ -2.55e-3 0.00198 -1.29 30.5 2.06e-1 -6.59e-3
## 6 ran_pars bw_id sd__(I~ 5.43e-2 NA NA NA NA NA
## 7 ran_pars Residual sd__Ob~ 1.76e-2 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
t25fw_home_multi_vid_adj <- lmer(t25fw_inverse ~
stride_time_median_sec_pose_hv +
log_delta_pix_h_rel_median_pose_hv +
mean_cadence_step_per_min_pose_hv +
stride_width_median_cm_pose_hv +
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = home_clean_df)
summary(t25fw_home_multi_vid_adj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## t25fw_inverse ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv +
## mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv +
## demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: home_clean_df
##
## REML criterion at convergence: -131.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.93370 -0.24197 -0.01113 0.21746 2.11490
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 0.001607 0.04009
## Residual 0.000242 0.01556
## Number of obs: 51, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 0.1866375 0.0821905 31.4403808
## stride_time_median_sec_pose_hv 0.0471890 0.0394827 37.9992439
## log_delta_pix_h_rel_median_pose_hv 0.0133408 0.0137909 30.2599418
## mean_cadence_step_per_min_pose_hv 0.0002295 0.0002397 28.0222212
## stride_width_median_cm_pose_hv -0.0011244 0.0018176 31.8904406
## demoEHR_Age -0.0004608 0.0009626 11.8621290
## demoEHR_DiseaseDuration -0.0011184 0.0014161 12.4423293
## ms_dx_condensedProgressive MS -0.1087408 0.0333150 21.3335450
## ms_dx_condensedMS, Subtype Not Specified 0.0019466 0.0376499 12.6659284
## race_ethnicity_cleanAsian 0.0803845 0.0471646 11.2833325
## race_ethnicity_cleanHispanic or Latino -0.0098782 0.0490510 11.5528452
## race_ethnicity_cleanOther/Unknown/Declined 0.0429345 0.0312136 11.3476499
## clean_sexMale 0.0550775 0.0255898 12.7789728
## t value Pr(>|t|)
## (Intercept) 2.271 0.03015 *
## stride_time_median_sec_pose_hv 1.195 0.23942
## log_delta_pix_h_rel_median_pose_hv 0.967 0.34103
## mean_cadence_step_per_min_pose_hv 0.957 0.34669
## stride_width_median_cm_pose_hv -0.619 0.54056
## demoEHR_Age -0.479 0.64084
## demoEHR_DiseaseDuration -0.790 0.44446
## ms_dx_condensedProgressive MS -3.264 0.00365 **
## ms_dx_condensedMS, Subtype Not Specified 0.052 0.95957
## race_ethnicity_cleanAsian 1.704 0.11567
## race_ethnicity_cleanHispanic or Latino -0.201 0.84390
## race_ethnicity_cleanOther/Unknown/Declined 1.376 0.19552
## clean_sexMale 2.152 0.05109 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation matrix not shown by default, as p = 13 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
# Residuals vs. fitted values
hist(resid(t25fw_home_multi_vid_adj), main = "Residuals All Video Metrics Adjusted")
# Normality check
qqnorm(residuals(t25fw_home_multi_vid_adj), main = "Normal Q-Q plot: Residuals All Video Metrics Adjusted")
# tidy results
t25fw_home_multi_vid_adj_df <- tidy(t25fw_home_multi_vid_adj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(t25fw_home_multi_vid_adj)$R2_conditional) %>%
mutate(R2_marginal = r2(t25fw_home_multi_vid_adj)$R2_marginal) %>%
mutate(Model = "Adjusted - Multivariate Video Metrics")
t25fw_home_multi_vid_adj_df
## # A tibble: 15 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inte~ 1.87e-1 0.0822 2.27 31.4 0.0302 1.91e-2
## 2 fixed <NA> strid~ 4.72e-2 0.0395 1.20 38.0 0.239 -3.27e-2
## 3 fixed <NA> log_d~ 1.33e-2 0.0138 0.967 30.3 0.341 -1.48e-2
## 4 fixed <NA> mean_~ 2.29e-4 0.000240 0.957 28.0 0.347 -2.62e-4
## 5 fixed <NA> strid~ -1.12e-3 0.00182 -0.619 31.9 0.541 -4.83e-3
## 6 fixed <NA> demoE~ -4.61e-4 0.000963 -0.479 11.9 0.641 -2.56e-3
## 7 fixed <NA> demoE~ -1.12e-3 0.00142 -0.790 12.4 0.444 -4.19e-3
## 8 fixed <NA> ms_dx~ -1.09e-1 0.0333 -3.26 21.3 0.00365 -1.78e-1
## 9 fixed <NA> ms_dx~ 1.95e-3 0.0376 0.0517 12.7 0.960 -7.96e-2
## 10 fixed <NA> race_~ 8.04e-2 0.0472 1.70 11.3 0.116 -2.31e-2
## 11 fixed <NA> race_~ -9.88e-3 0.0491 -0.201 11.6 0.844 -1.17e-1
## 12 fixed <NA> race_~ 4.29e-2 0.0312 1.38 11.3 0.196 -2.55e-2
## 13 fixed <NA> clean~ 5.51e-2 0.0256 2.15 12.8 0.0511 -3.03e-4
## 14 ran_pars bw_id sd__(~ 4.01e-2 NA NA NA NA NA
## 15 ran_pars Residual sd__O~ 1.56e-2 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
p value < 0.05, more complex model is significantly better than the simpler model
https://bookdown.org/ndphillips/YaRrr/comparing-regression-models-with-anova.html
# Demographics only vs Video + Demographics
anova(t25fw_home_multi_dem, t25fw_home_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: home_clean_df
## Models:
## t25fw_home_multi_dem: t25fw_inverse ~ demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## t25fw_home_multi_vid_adj: t25fw_inverse ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv + mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## t25fw_home_multi_dem 11 -207.16 -185.91 114.58 -229.16
## t25fw_home_multi_vid_adj 15 -204.58 -175.60 117.29 -234.58 5.4226 4
## Pr(>Chisq)
## t25fw_home_multi_dem
## t25fw_home_multi_vid_adj 0.2466
# Video only vs Video + Demographics
anova(t25fw_home_multi_vid_unadj, t25fw_home_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: home_clean_df
## Models:
## t25fw_home_multi_vid_unadj: t25fw_inverse ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv + mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv + (1 | bw_id)
## t25fw_home_multi_vid_adj: t25fw_inverse ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv + mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## t25fw_home_multi_vid_unadj 7 -189.08 -175.56 101.54 -203.08
## t25fw_home_multi_vid_adj 15 -204.58 -175.60 117.29 -234.58 31.505 8
## Pr(>Chisq)
## t25fw_home_multi_vid_unadj
## t25fw_home_multi_vid_adj 0.0001142 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t25fw_home_multivar_all <- bind_rows(t25fw_home_multi_dem_df,
t25fw_home_multi_vid_unadj_df,
t25fw_home_multi_vid_adj_df)
# save R-squared
adj_r_squared_df <- t25fw_home_multivar_all[c('Model', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 3 x 3
## Model R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Unadjusted - Multivariate Demographics and MS Info 0.95 0.62
## 2 Unadjusted - Multivariate Video Metrics 0.91 0.08
## 3 Adjusted - Multivariate Video Metrics 0.95 0.62
write.csv(adj_r_squared_df, file.path(output_dir, 't25fw_inverse_adj_vs_unadj_home_r2.csv'))
p <- adj_vs_unadj_plot(results_df = t25fw_home_multivar_all,
plot_title = "Home: Inverse T25FW Unadjusted vs Adjusted",
x_adj = 0.1)
p
ggsave(file.path(output_dir, 't25fw_inverse_adj_vs_unadj_home_estimates.png'),
bg = "white", width= 12, height=10)
Preferred Walking Speed
# preferred walking speed
ggplot(data = zeno_pws_df, mapping = aes(PWS_velocitycmsecmean)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# log
zeno_pws_df$log_PWS_velocity <- log(zeno_pws_df$PWS_velocitycmsecmean)
ggplot(data = zeno_pws_df, mapping = aes(log_PWS_velocity)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# inverse
zeno_pws_df$inv_PWS_velocity <- 1 / zeno_pws_df$PWS_velocitycmsecmean
ggplot(data = zeno_pws_df, mapping = aes(inv_PWS_velocity)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Fast Walking Speed
# fast walking speed
ggplot(data = zeno_fw_df, mapping = aes(FW_velocitycmsecmean)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# log
zeno_fw_df$log_FW_velocity <- log(zeno_fw_df$FW_velocitycmsecmean)
ggplot(data = zeno_fw_df, mapping = aes(log_FW_velocity)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# inverse
zeno_fw_df$inv_FW_velocity <- 1 / zeno_fw_df$FW_velocitycmsecmean
ggplot(data = zeno_fw_df, mapping = aes(inv_FW_velocity)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# square root
zeno_fw_df$sqrt_FW_velocity <- sqrt(zeno_fw_df$FW_velocitycmsecmean)
ggplot(data = zeno_fw_df, mapping = aes(sqrt_FW_velocity)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Home Videos - most recent PWS
# fast walking speed
ggplot(data = home_df, mapping = aes(PWS_velocitycmsecmean)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# log
home_df$log_PWS_velocity <- log(home_df$PWS_velocitycmsecmean)
ggplot(data = home_df, mapping = aes(log_PWS_velocity)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# inverse
home_df$inv_PWS_velocity <- 1 / home_df$PWS_velocitycmsecmean
ggplot(data = home_df, mapping = aes(inv_PWS_velocity)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# square root
home_df$sqrt_PWS_velocity <- sqrt(home_df$PWS_velocitycmsecmean)
ggplot(data = home_df, mapping = aes(sqrt_PWS_velocity)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
uni_zv_pws_pwsvel <- all_univariate_mixed_effect(data = zeno_pws_df,
outcome_column = "PWS_velocitycmsecmean")
## [1] "log_delta_pix_h_rel_median_pose"
## Warning: Removed 16 rows containing missing values (`geom_point()`).
## PWS_velocitycmsecmean ~ log_delta_pix_h_rel_median_pose + (1 |
## bw_id)
## <environment: 0x00000000303ff690>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula1
## Data: data
##
## REML criterion at convergence: 1913
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.66513 -0.45718 0.06148 0.43131 1.82904
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 489.3 22.12
## Residual 225.2 15.01
## Number of obs: 208, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 128.053 4.925 181.126 26.000 < 2e-16
## log_delta_pix_h_rel_median_pose 18.038 3.134 150.731 5.755 4.7e-08
##
## (Intercept) ***
## log_delta_pix_h_rel_median_pose ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## lg_dlt_____ 0.906
## [1] "stride_time_median_sec_pose"
## Warning: Removed 48 rows containing missing values (`geom_point()`).
## PWS_velocitycmsecmean ~ stride_time_median_sec_pose + (1 | bw_id)
## <environment: 0x00000000303ff690>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula2
## Data: data
##
## REML criterion at convergence: 1582.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.73475 -0.46264 0.08608 0.52814 2.10338
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 275.9 16.61
## Residual 271.1 16.46
## Number of obs: 176, groups: bw_id, 128
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 180.45 12.18 144.58 14.815 < 2e-16 ***
## stride_time_median_sec_pose -67.85 10.66 140.48 -6.365 2.59e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_tm_m__ -0.987
## [1] "mean_cadence_step_per_min_pose"
## Warning: Removed 40 rows containing missing values (`geom_point()`).
## PWS_velocitycmsecmean ~ mean_cadence_step_per_min_pose + (1 |
## bw_id)
## <environment: 0x00000000303ff690>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula3
## Data: data
##
## REML criterion at convergence: 1663.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9411 -0.4531 0.0404 0.5730 1.4936
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 334.5 18.29
## Residual 232.7 15.25
## Number of obs: 184, groups: bw_id, 132
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 16.6310 11.8367 171.3552 1.405 0.162
## mean_cadence_step_per_min_pose 0.8334 0.1130 169.2633 7.376 6.96e-12
##
## (Intercept)
## mean_cadence_step_per_min_pose ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mn_cdnc____ -0.986
## [1] "stride_width_median_cm_pose"
## Warning: Removed 40 rows containing missing values (`geom_point()`).
## PWS_velocitycmsecmean ~ stride_width_median_cm_pose + (1 | bw_id)
## <environment: 0x00000000303ff690>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula4
## Data: data
##
## REML criterion at convergence: 1701.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.00080 -0.39103 0.07425 0.47990 1.74120
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 502.0 22.41
## Residual 245.4 15.66
## Number of obs: 184, groups: bw_id, 132
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 116.9113 7.2951 173.5963 16.026 <2e-16 ***
## stride_width_median_cm_pose -1.1348 0.5514 164.1555 -2.058 0.0412 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_wdt___ -0.949
## [1] "demoEHR_Age"
## PWS_velocitycmsecmean ~ demoEHR_Age + (1 | bw_id)
## <environment: 0x00000000303ff690>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula5
## Data: data
##
## REML criterion at convergence: 2076.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.94413 -0.36526 0.04794 0.34376 1.89415
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 666.5 25.82
## Residual 187.3 13.69
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 126.5386 9.2830 153.9318 13.631 < 2e-16 ***
## demoEHR_Age -0.4796 0.1791 154.7347 -2.677 0.00823 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## demoEHR_Age -0.969
## [1] "demoEHR_DiseaseDuration"
## PWS_velocitycmsecmean ~ demoEHR_DiseaseDuration + (1 | bw_id)
## <environment: 0x00000000303ff690>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula6
## Data: data
##
## REML criterion at convergence: 2081.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9000 -0.3766 0.0352 0.3760 1.9269
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 694.0 26.34
## Residual 188.9 13.74
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 105.5672 3.7214 153.9227 28.368 <2e-16 ***
## demoEHR_DiseaseDuration -0.3184 0.2964 153.7503 -1.074 0.284
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## dmEHR_DssDr -0.779
## [1] "ms_dx_condensed"
## PWS_velocitycmsecmean ~ ms_dx_condensed + (1 | bw_id)
## <environment: 0x00000000303ff690>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula7
## Data: data
##
## REML criterion at convergence: 2024.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.00088 -0.38645 0.03448 0.38824 1.94371
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 504.4 22.46
## Residual 182.8 13.52
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 109.276 2.287 152.631 47.790
## ms_dx_condensedProgressive MS -37.122 5.262 155.734 -7.055
## ms_dx_condensedMS, Subtype Not Specified 11.522 18.010 150.601 0.640
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## ms_dx_condensedProgressive MS 5.33e-11 ***
## ms_dx_condensedMS, Subtype Not Specified 0.523
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) m__PMS
## ms_dx_cnPMS -0.435
## ms_d_MS,SNS -0.127 0.055
## [1] "race_ethnicity_clean"
## PWS_velocitycmsecmean ~ race_ethnicity_clean + (1 | bw_id)
## <environment: 0x00000000303ff690>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula8
## Data: data
##
## REML criterion at convergence: 2051.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.90162 -0.35360 0.02896 0.38133 1.94146
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 687.1 26.21
## Residual 187.1 13.68
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 102.9381 2.8117 148.0586
## race_ethnicity_cleanAsian 4.0172 9.1090 146.5408
## race_ethnicity_cleanBlack Or African American -20.2064 9.2122 153.5385
## race_ethnicity_cleanHispanic or Latino 0.5128 7.9700 149.4285
## race_ethnicity_cleanOther/Unknown/Declined 7.6193 8.7771 147.8014
## t value Pr(>|t|)
## (Intercept) 36.610 <2e-16 ***
## race_ethnicity_cleanAsian 0.441 0.6598
## race_ethnicity_cleanBlack Or African American -2.193 0.0298 *
## race_ethnicity_cleanHispanic or Latino 0.064 0.9488
## race_ethnicity_cleanOther/Unknown/Declined 0.868 0.3868
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rc_t_A r__OAA r__HoL
## rc_thncty_A -0.309
## rc_thn_BOAA -0.305 0.094
## rc_thnc_HoL -0.353 0.109 0.108
## rc_th_O/U/D -0.320 0.099 0.098 0.113
## [1] "clean_sex"
## PWS_velocitycmsecmean ~ clean_sex + (1 | bw_id)
## <environment: 0x00000000303ff690>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula9
## Data: data
##
## REML criterion at convergence: 2067.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.90390 -0.35516 0.03233 0.37135 1.97743
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 710.2 26.65
## Residual 186.6 13.66
## Number of obs: 224, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 102.1214 2.7247 150.6754 37.480 <2e-16 ***
## clean_sexMale 0.8422 5.4739 151.4409 0.154 0.878
## clean_sexNon-Binary 17.3286 28.4765 133.6691 0.609 0.544
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) cln_sM
## clean_sexMl -0.498
## cln_sxNn-Bn -0.096 0.048
# save adjusted r_squared
adj_r_squared_df <- uni_zv_pws_pwsvel[c('Variable', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 9 x 3
## Variable R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Log Pixel Height Proxy 0.72 0.11
## 2 Stride Time - Median 0.59 0.17
## 3 Cadence - Mean 0.68 0.21
## 4 Stride Width - Median 0.68 0.02
## 5 Age 0.79 0.04
## 6 Disease Duration 0.79 0.01
## 7 MS DX 0.8 0.23
## 8 Race and Ethnicity 0.79 0.03
## 9 Sex 0.79 0
write.csv(adj_r_squared_df, file.path(output_dir, 'ZenoVelPws_univariate_pws_r2.csv'))
# Plot estimates
p <- univariate_regression_plot(results = uni_zv_pws_pwsvel,
plot_title = "PWS Univariate - lmer(Zeno Mat Velocity ~ Predictor + (1 | bw_id))",
x_adj = 15)
p
ggsave(file.path(output_dir, 'ZenoVelPws_univariate_pws_estimates.png'),
bg = "white", width= 10, height=10)
pwsVel_pws_multi_dem <- lmer(PWS_velocitycmsecmean ~
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = zeno_pws_clean_df)
summary(pwsVel_pws_multi_dem)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PWS_velocitycmsecmean ~ demoEHR_Age + demoEHR_DiseaseDuration +
## ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: zeno_pws_clean_df
##
## REML criterion at convergence: 1416.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.98899 -0.41289 0.05874 0.44493 1.73443
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 436.0 20.88
## Residual 189.8 13.78
## Number of obs: 162, groups: bw_id, 127
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 119.11391 10.86298 115.42984
## demoEHR_Age -0.21920 0.22404 118.39410
## demoEHR_DiseaseDuration 0.12505 0.31794 114.91096
## ms_dx_condensedProgressive MS -28.93353 6.36640 117.89377
## ms_dx_condensedMS, Subtype Not Specified 15.48659 18.29132 125.53293
## race_ethnicity_cleanAsian 0.07824 9.37501 117.49770
## race_ethnicity_cleanBlack Or African American -25.61581 8.56468 111.51624
## race_ethnicity_cleanHispanic or Latino 2.50555 7.63177 114.69685
## race_ethnicity_cleanOther/Unknown/Declined -5.99989 9.65149 118.77113
## clean_sexMale 1.02687 5.07064 117.25922
## clean_sexNon-Binary 6.73315 25.37795 125.89521
## t value Pr(>|t|)
## (Intercept) 10.965 < 2e-16 ***
## demoEHR_Age -0.978 0.32987
## demoEHR_DiseaseDuration 0.393 0.69482
## ms_dx_condensedProgressive MS -4.545 1.34e-05 ***
## ms_dx_condensedMS, Subtype Not Specified 0.847 0.39879
## race_ethnicity_cleanAsian 0.008 0.99336
## race_ethnicity_cleanBlack Or African American -2.991 0.00342 **
## race_ethnicity_cleanHispanic or Latino 0.328 0.74328
## race_ethnicity_cleanOther/Unknown/Declined -0.622 0.53536
## clean_sexMale 0.203 0.83987
## clean_sexNon-Binary 0.265 0.79120
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) dEHR_A dEHR_D m__PMS m__SNS rc_t_A r__OAA r__HoL r__O/U
## demoEHR_Age -0.920
## dmEHR_DssDr 0.185 -0.457
## ms_dx_cnPMS 0.120 -0.180 -0.119
## ms_d_MS,SNS 0.129 -0.142 -0.045 0.114
## rc_thncty_A -0.286 0.217 -0.032 -0.012 0.007
## rc_thn_BOAA -0.162 0.075 -0.005 0.040 0.032 0.106
## rc_thnc_HoL -0.313 0.236 -0.047 0.032 0.023 0.166 0.128
## rc_th_O/U/D -0.351 0.252 -0.032 0.052 -0.009 0.136 0.117 0.153
## clean_sexMl -0.151 0.030 0.002 0.002 -0.075 -0.052 0.028 -0.127 0.142
## cln_sxNn-Bn -0.055 -0.012 0.106 0.022 0.002 0.034 0.039 0.038 0.048
## cln_sM
## demoEHR_Age
## dmEHR_DssDr
## ms_dx_cnPMS
## ms_d_MS,SNS
## rc_thncty_A
## rc_thn_BOAA
## rc_thnc_HoL
## rc_th_O/U/D
## clean_sexMl
## cln_sxNn-Bn 0.052
# Residuals vs. fitted values
hist(resid(pwsVel_pws_multi_dem), main = "Residuals All Demographic and MS Info")
# Normality check
qqnorm(residuals(pwsVel_pws_multi_dem), main = "Normal Q-Q plot: Residuals All Demographic and MS Info")
# tidy results
pwsVel_pws_multi_dem_df <- tidy(pwsVel_pws_multi_dem, conf.int = TRUE) %>%
mutate(R2_conditional = r2(pwsVel_pws_multi_dem)$R2_conditional) %>%
mutate(R2_marginal = r2(pwsVel_pws_multi_dem)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Demographics and MS Info")
pwsVel_pws_multi_dem_df
## # A tibble: 13 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Int~ 119. 10.9 11.0 115. 1.33e-19 97.6
## 2 fixed <NA> demo~ -0.219 0.224 -0.978 118. 3.30e- 1 -0.663
## 3 fixed <NA> demo~ 0.125 0.318 0.393 115. 6.95e- 1 -0.505
## 4 fixed <NA> ms_d~ -28.9 6.37 -4.54 118. 1.34e- 5 -41.5
## 5 fixed <NA> ms_d~ 15.5 18.3 0.847 126. 3.99e- 1 -20.7
## 6 fixed <NA> race~ 0.0782 9.38 0.00835 117. 9.93e- 1 -18.5
## 7 fixed <NA> race~ -25.6 8.56 -2.99 112. 3.42e- 3 -42.6
## 8 fixed <NA> race~ 2.51 7.63 0.328 115. 7.43e- 1 -12.6
## 9 fixed <NA> race~ -6.00 9.65 -0.622 119. 5.35e- 1 -25.1
## 10 fixed <NA> clea~ 1.03 5.07 0.203 117. 8.40e- 1 -9.02
## 11 fixed <NA> clea~ 6.73 25.4 0.265 126. 7.91e- 1 -43.5
## 12 ran_pars bw_id sd__~ 20.9 NA NA NA NA NA
## 13 ran_pars Residual sd__~ 13.8 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
pwsVel_pws_multi_vid_unadj <- lmer(PWS_velocitycmsecmean ~
stride_time_median_sec_pose_zv +
log_delta_pix_h_rel_median_pose_zv +
mean_cadence_step_per_min_pose_zv +
stride_width_median_cm_pose_zv +
(1|bw_id),
data = zeno_pws_clean_df)
summary(pwsVel_pws_multi_vid_unadj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## PWS_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv +
## mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv +
## (1 | bw_id)
## Data: zeno_pws_clean_df
##
## REML criterion at convergence: 1431.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.86529 -0.45371 0.05271 0.54598 1.30773
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 262.4 16.20
## Residual 222.8 14.92
## Number of obs: 162, groups: bw_id, 127
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 116.1956 32.0769 107.4974 3.622
## stride_time_median_sec_pose_zv -44.4045 14.5072 97.6776 -3.061
## log_delta_pix_h_rel_median_pose_zv 2.1329 3.5858 118.9712 0.595
## mean_cadence_step_per_min_pose_zv 0.5638 0.1718 111.2112 3.281
## stride_width_median_cm_pose_zv -1.4834 0.5452 156.6905 -2.721
## Pr(>|t|)
## (Intercept) 0.000447 ***
## stride_time_median_sec_pose_zv 0.002850 **
## log_delta_pix_h_rel_median_pose_zv 0.553106
## mean_cadence_step_per_min_pose_zv 0.001381 **
## stride_width_median_cm_pose_zv 0.007248 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) strd_t____ l_____ m_____
## strd_tm____ -0.811
## lg_dl______ 0.102 0.205
## mn_cdn_____ -0.903 0.582 -0.121
## strd_wd____ -0.286 0.037 0.099 0.124
# Residuals vs. fitted values
hist(resid(pwsVel_pws_multi_vid_unadj), main = "Residuals All Video Metrics Unadjusted")
# Normality check
qqnorm(residuals(pwsVel_pws_multi_vid_unadj), main = "Normal Q-Q plot: Residuals All Video Metrics Unadjusted")
# tidy results
pwsVel_pws_multi_vid_unadj_df <- tidy(pwsVel_pws_multi_vid_unadj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(pwsVel_pws_multi_vid_unadj)$R2_conditional) %>%
mutate(R2_marginal = r2(pwsVel_pws_multi_vid_unadj)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Video Metrics")
pwsVel_pws_multi_vid_unadj_df
## # A tibble: 7 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inter~ 116. 32.1 3.62 107. 4.47e-4 52.6
## 2 fixed <NA> stride~ -44.4 14.5 -3.06 97.7 2.85e-3 -73.2
## 3 fixed <NA> log_de~ 2.13 3.59 0.595 119. 5.53e-1 -4.97
## 4 fixed <NA> mean_c~ 0.564 0.172 3.28 111. 1.38e-3 0.223
## 5 fixed <NA> stride~ -1.48 0.545 -2.72 157. 7.25e-3 -2.56
## 6 ran_pars bw_id sd__(I~ 16.2 NA NA NA NA NA
## 7 ran_pars Residual sd__Ob~ 14.9 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
pwsVel_pws_multi_vid_adj <- lmer(PWS_velocitycmsecmean ~
stride_time_median_sec_pose_zv +
log_delta_pix_h_rel_median_pose_zv +
mean_cadence_step_per_min_pose_zv +
stride_width_median_cm_pose_zv +
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = zeno_pws_clean_df)
summary(pwsVel_pws_multi_vid_adj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## PWS_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv +
## mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv +
## demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: zeno_pws_clean_df
##
## REML criterion at convergence: 1361
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.91825 -0.50698 0.06095 0.56417 1.47833
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 224.0 14.97
## Residual 213.6 14.61
## Number of obs: 162, groups: bw_id, 127
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 100.1378 33.6497 113.7658
## stride_time_median_sec_pose_zv -34.4029 14.4747 99.5882
## log_delta_pix_h_rel_median_pose_zv 0.2555 3.5953 114.5385
## mean_cadence_step_per_min_pose_zv 0.6566 0.1711 107.7974
## stride_width_median_cm_pose_zv -0.7604 0.5647 146.9866
## demoEHR_Age -0.2565 0.1854 108.9989
## demoEHR_DiseaseDuration -0.1670 0.2648 101.8196
## ms_dx_condensedProgressive MS -13.5472 5.9343 116.3875
## ms_dx_condensedMS, Subtype Not Specified 14.1187 15.3541 125.8439
## race_ethnicity_cleanAsian -1.9507 7.8698 109.4660
## race_ethnicity_cleanBlack Or African American -22.2538 7.1440 99.6541
## race_ethnicity_cleanHispanic or Latino 1.6386 6.2964 102.2530
## race_ethnicity_cleanOther/Unknown/Declined -0.1223 8.0998 115.0832
## clean_sexMale 4.9404 4.2930 109.6597
## clean_sexNon-Binary 1.0418 21.2748 126.2811
## t value Pr(>|t|)
## (Intercept) 2.976 0.00357 **
## stride_time_median_sec_pose_zv -2.377 0.01938 *
## log_delta_pix_h_rel_median_pose_zv 0.071 0.94347
## mean_cadence_step_per_min_pose_zv 3.837 0.00021 ***
## stride_width_median_cm_pose_zv -1.347 0.18020
## demoEHR_Age -1.384 0.16925
## demoEHR_DiseaseDuration -0.631 0.52955
## ms_dx_condensedProgressive MS -2.283 0.02425 *
## ms_dx_condensedMS, Subtype Not Specified 0.920 0.35957
## race_ethnicity_cleanAsian -0.248 0.80470
## race_ethnicity_cleanBlack Or African American -3.115 0.00240 **
## race_ethnicity_cleanHispanic or Latino 0.260 0.79519
## race_ethnicity_cleanOther/Unknown/Declined -0.015 0.98798
## clean_sexMale 1.151 0.25231
## clean_sexNon-Binary 0.049 0.96102
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation matrix not shown by default, as p = 15 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
# Residuals vs. fitted values
hist(resid(pwsVel_pws_multi_vid_adj), main = "Residuals All Video Metrics Adjusted")
# Normality check
qqnorm(residuals(pwsVel_pws_multi_vid_adj), main = "Normal Q-Q plot: Residuals All Video Metrics Adjusted")
# tidy results
pwsVel_pws_multi_vid_adj_df <- tidy(pwsVel_pws_multi_vid_adj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(pwsVel_pws_multi_vid_adj)$R2_conditional) %>%
mutate(R2_marginal = r2(pwsVel_pws_multi_vid_adj)$R2_marginal) %>%
mutate(Model = "Adjusted - Multivariate Video Metrics")
pwsVel_pws_multi_vid_adj_df
## # A tibble: 17 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inte~ 100. 33.6 2.98 114. 3.57e-3 33.5
## 2 fixed <NA> strid~ -34.4 14.5 -2.38 99.6 1.94e-2 -63.1
## 3 fixed <NA> log_d~ 0.255 3.60 0.0711 115. 9.43e-1 -6.87
## 4 fixed <NA> mean_~ 0.657 0.171 3.84 108. 2.10e-4 0.317
## 5 fixed <NA> strid~ -0.760 0.565 -1.35 147. 1.80e-1 -1.88
## 6 fixed <NA> demoE~ -0.257 0.185 -1.38 109. 1.69e-1 -0.624
## 7 fixed <NA> demoE~ -0.167 0.265 -0.631 102. 5.30e-1 -0.692
## 8 fixed <NA> ms_dx~ -13.5 5.93 -2.28 116. 2.43e-2 -25.3
## 9 fixed <NA> ms_dx~ 14.1 15.4 0.920 126. 3.60e-1 -16.3
## 10 fixed <NA> race_~ -1.95 7.87 -0.248 109. 8.05e-1 -17.5
## 11 fixed <NA> race_~ -22.3 7.14 -3.12 99.7 2.40e-3 -36.4
## 12 fixed <NA> race_~ 1.64 6.30 0.260 102. 7.95e-1 -10.8
## 13 fixed <NA> race_~ -0.122 8.10 -0.0151 115. 9.88e-1 -16.2
## 14 fixed <NA> clean~ 4.94 4.29 1.15 110. 2.52e-1 -3.57
## 15 fixed <NA> clean~ 1.04 21.3 0.0490 126. 9.61e-1 -41.1
## 16 ran_pars bw_id sd__(~ 15.0 NA NA NA NA NA
## 17 ran_pars Residual sd__O~ 14.6 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
p value < 0.05, more complex model is significantly better than the simpler model
https://bookdown.org/ndphillips/YaRrr/comparing-regression-models-with-anova.html
# Demographics only vs Video + Demographics
anova(pwsVel_pws_multi_dem, pwsVel_pws_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: zeno_pws_clean_df
## Models:
## pwsVel_pws_multi_dem: PWS_velocitycmsecmean ~ demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## pwsVel_pws_multi_vid_adj: PWS_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## pwsVel_pws_multi_dem 13 1493.9 1534.0 -733.96 1467.9
## pwsVel_pws_multi_vid_adj 17 1452.3 1504.8 -709.16 1418.3 49.596 4
## Pr(>Chisq)
## pwsVel_pws_multi_dem
## pwsVel_pws_multi_vid_adj 4.386e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Video only vs Video + Demographics
anova(pwsVel_pws_multi_vid_unadj, pwsVel_pws_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: zeno_pws_clean_df
## Models:
## pwsVel_pws_multi_vid_unadj: PWS_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + (1 | bw_id)
## pwsVel_pws_multi_vid_adj: PWS_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## pwsVel_pws_multi_vid_unadj 7 1458.3 1479.9 -722.14 1444.3
## pwsVel_pws_multi_vid_adj 17 1452.3 1504.8 -709.16 1418.3 25.97 10
## Pr(>Chisq)
## pwsVel_pws_multi_vid_unadj
## pwsVel_pws_multi_vid_adj 0.003781 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pwsVel_pws_multivar_all <- bind_rows(pwsVel_pws_multi_dem_df,
pwsVel_pws_multi_vid_unadj_df,
pwsVel_pws_multi_vid_adj_df)
# save R-squared
adj_r_squared_df <- pwsVel_pws_multivar_all[c('Model', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 3 x 3
## Model R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Unadjusted - Multivariate Demographics and MS Info 0.76 0.21
## 2 Unadjusted - Multivariate Video Metrics 0.69 0.32
## 3 Adjusted - Multivariate Video Metrics 0.72 0.42
write.csv(adj_r_squared_df, file.path(output_dir, 'ZenoVelPws_adj_vs_unadj_pws_r2.csv'))
p <- adj_vs_unadj_plot(results_df = pwsVel_pws_multivar_all,
plot_title = "PWS: PWS Mat Velocity Unadjusted vs Adjusted",
x_adj = 30)
p
ggsave(file.path(output_dir, 'ZenoVelPws_adj_vs_unadj_pws_estimates.png'),
bg = "white", width= 12, height=10)
uni_zv_fw_fwvel <- all_univariate_mixed_effect(data = zeno_fw_df,
outcome_column = "FW_velocitycmsecmean")
## [1] "log_delta_pix_h_rel_median_pose"
## Warning: Removed 4 rows containing missing values (`geom_point()`).
## FW_velocitycmsecmean ~ log_delta_pix_h_rel_median_pose + (1 |
## bw_id)
## <environment: 0x000000002b9f8fa8>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula1
## Data: data
##
## REML criterion at convergence: 2123.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.8984 -0.4910 -0.0405 0.5122 3.8087
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 409.0 20.22
## Residual 686.3 26.20
## Number of obs: 218, groups: bw_id, 152
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 198.547 4.986 209.813 39.82 <2e-16
## log_delta_pix_h_rel_median_pose 47.532 4.066 213.984 11.69 <2e-16
##
## (Intercept) ***
## log_delta_pix_h_rel_median_pose ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## lg_dlt_____ 0.870
## [1] "stride_time_median_sec_pose"
## Warning: Removed 53 rows containing missing values (`geom_point()`).
## FW_velocitycmsecmean ~ stride_time_median_sec_pose + (1 | bw_id)
## <environment: 0x000000002b9f8fa8>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula2
## Data: data
##
## REML criterion at convergence: 1642
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.63128 -0.42916 0.00867 0.45414 2.95998
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 504.3 22.46
## Residual 609.9 24.70
## Number of obs: 169, groups: bw_id, 126
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 288.84 15.04 155.63 19.207 <2e-16 ***
## stride_time_median_sec_pose -147.45 15.53 159.51 -9.492 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_tm_m__ -0.982
## [1] "mean_cadence_step_per_min_pose"
## Warning: Removed 46 rows containing missing values (`geom_point()`).
## FW_velocitycmsecmean ~ mean_cadence_step_per_min_pose + (1 |
## bw_id)
## <environment: 0x000000002b9f8fa8>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula3
## Data: data
##
## REML criterion at convergence: 1757.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.18927 -0.57963 0.01518 0.54555 2.08844
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 488.6 22.10
## Residual 859.3 29.31
## Number of obs: 176, groups: bw_id, 129
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 22.8532 15.4932 170.9643 1.475 0.142
## mean_cadence_step_per_min_pose 1.0376 0.1273 170.5877 8.149 7.51e-14
##
## (Intercept)
## mean_cadence_step_per_min_pose ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mn_cdnc____ -0.981
## [1] "stride_width_median_cm_pose"
## Warning: Removed 47 rows containing missing values (`geom_point()`).
## FW_velocitycmsecmean ~ stride_width_median_cm_pose + (1 | bw_id)
## <environment: 0x000000002b9f8fa8>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula4
## Data: data
##
## REML criterion at convergence: 1774.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.50008 -0.27623 0.03442 0.41610 1.94751
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 1268.4 35.61
## Residual 579.6 24.07
## Number of obs: 175, groups: bw_id, 128
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 182.2706 12.3191 134.9088 14.796 < 2e-16 ***
## stride_width_median_cm_pose -2.9836 0.9725 121.6592 -3.068 0.00266 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_wdt___ -0.954
## [1] "demoEHR_Age"
## FW_velocitycmsecmean ~ demoEHR_Age + (1 | bw_id)
## <environment: 0x000000002b9f8fa8>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula5
## Data: data
##
## REML criterion at convergence: 2224.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.74601 -0.33528 0.04748 0.37615 2.20638
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 1330.9 36.48
## Residual 426.4 20.65
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 208.8291 13.2897 152.4750 15.714 < 2e-16 ***
## demoEHR_Age -1.2409 0.2566 153.5144 -4.837 3.18e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## demoEHR_Age -0.969
## [1] "demoEHR_DiseaseDuration"
## FW_velocitycmsecmean ~ demoEHR_DiseaseDuration + (1 | bw_id)
## <environment: 0x000000002b9f8fa8>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula6
## Data: data
##
## REML criterion at convergence: 2240.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.85661 -0.30254 0.01094 0.39170 2.28142
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 1569.3 39.61
## Residual 413.9 20.35
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 155.3424 5.5883 153.1485 27.798 <2e-16 ***
## demoEHR_DiseaseDuration -0.9115 0.4466 154.2343 -2.041 0.043 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## dmEHR_DssDr -0.779
## [1] "ms_dx_condensed"
## FW_velocitycmsecmean ~ ms_dx_condensed + (1 | bw_id)
## <environment: 0x000000002b9f8fa8>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula7
## Data: data
##
## REML criterion at convergence: 2178.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.62728 -0.35557 0.01123 0.42904 2.30067
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 1070.6 32.72
## Residual 413.1 20.33
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 158.043 3.354 151.628 47.122
## ms_dx_condensedProgressive MS -60.295 7.737 156.200 -7.793
## ms_dx_condensedMS, Subtype Not Specified -17.697 27.443 173.070 -0.645
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## ms_dx_condensedProgressive MS 8.58e-13 ***
## ms_dx_condensedMS, Subtype Not Specified 0.52
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) m__PMS
## ms_dx_cnPMS -0.433
## ms_d_MS,SNS -0.122 0.053
## [1] "race_ethnicity_clean"
## FW_velocitycmsecmean ~ race_ethnicity_clean + (1 | bw_id)
## <environment: 0x000000002b9f8fa8>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula8
## Data: data
##
## REML criterion at convergence: 2207.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.85257 -0.34419 0.00005 0.38680 2.29436
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 1509.2 38.85
## Residual 425.2 20.62
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 148.913 4.182 146.728
## race_ethnicity_cleanAsian -11.056 13.539 144.842
## race_ethnicity_cleanBlack Or African American -36.411 13.697 152.121
## race_ethnicity_cleanHispanic or Latino -2.783 11.889 149.976
## race_ethnicity_cleanOther/Unknown/Declined 15.269 13.047 146.153
## t value Pr(>|t|)
## (Intercept) 35.611 < 2e-16 ***
## race_ethnicity_cleanAsian -0.817 0.41549
## race_ethnicity_cleanBlack Or African American -2.658 0.00869 **
## race_ethnicity_cleanHispanic or Latino -0.234 0.81525
## race_ethnicity_cleanOther/Unknown/Declined 1.170 0.24377
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rc_t_A r__OAA r__HoL
## rc_thncty_A -0.309
## rc_thn_BOAA -0.305 0.094
## rc_thnc_HoL -0.352 0.109 0.107
## rc_th_O/U/D -0.321 0.099 0.098 0.113
## [1] "clean_sex"
## FW_velocitycmsecmean ~ clean_sex + (1 | bw_id)
## <environment: 0x000000002b9f8fa8>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula9
## Data: data
##
## REML criterion at convergence: 2227.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.8099 -0.3291 0.0184 0.3878 2.3219
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 1583.8 39.80
## Residual 423.3 20.57
## Number of obs: 222, groups: bw_id, 154
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 143.872 4.077 149.599 35.292 <2e-16 ***
## clean_sexMale 9.645 8.196 150.844 1.177 0.241
## clean_sexNon-Binary 32.050 42.568 131.966 0.753 0.453
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) cln_sM
## clean_sexMl -0.497
## cln_sxNn-Bn -0.096 0.048
# save adjusted r_squared
adj_r_squared_df <- uni_zv_fw_fwvel[c('Variable', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 9 x 3
## Variable R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Log Pixel Height Proxy 0.61 0.38
## 2 Stride Time - Median 0.65 0.35
## 3 Cadence - Mean 0.54 0.28
## 4 Stride Width - Median 0.7 0.04
## 5 Age 0.79 0.12
## 6 Disease Duration 0.8 0.03
## 7 MS DX 0.79 0.26
## 8 Race and Ethnicity 0.79 0.05
## 9 Sex 0.79 0.01
write.csv(adj_r_squared_df, file.path(output_dir, 'ZenoVelFw_univariate_fw_r2.csv'))
# Plot estimates
p <- univariate_regression_plot(results = uni_zv_fw_fwvel,
plot_title = "FW Univariate - lmer(Zeno Mat Velocity ~ Predictor + (1 | bw_id))",
x_adj = 15)
p
ggsave(file.path(output_dir, 'ZenoVelFw_univariate_fw_estimates.png'),
bg = "white", width= 10, height=10)
fwVel_fw_multi_dem <- lmer(FW_velocitycmsecmean ~
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = zeno_fw_clean_df)
summary(fwVel_fw_multi_dem)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: FW_velocitycmsecmean ~ demoEHR_Age + demoEHR_DiseaseDuration +
## ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: zeno_fw_clean_df
##
## REML criterion at convergence: 1571.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.22452 -0.40797 0.02676 0.40013 2.21919
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 891.0 29.85
## Residual 400.1 20.00
## Number of obs: 167, groups: bw_id, 125
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 206.8403 15.5531 119.7069
## demoEHR_Age -0.9585 0.3086 122.3187
## demoEHR_DiseaseDuration 0.2485 0.4601 115.5376
## ms_dx_condensedProgressive MS -49.3331 9.1143 119.4695
## ms_dx_condensedMS, Subtype Not Specified -16.7360 37.4419 127.5203
## race_ethnicity_cleanAsian -22.3427 12.2269 116.4010
## race_ethnicity_cleanBlack Or African American -51.8062 12.3392 114.3895
## race_ethnicity_cleanHispanic or Latino -15.6399 11.1026 115.1932
## race_ethnicity_cleanOther/Unknown/Declined -5.4296 12.6180 118.6096
## clean_sexMale 7.1075 7.4584 115.1542
## clean_sexNon-Binary 13.1729 33.6699 92.5670
## t value Pr(>|t|)
## (Intercept) 13.299 < 2e-16 ***
## demoEHR_Age -3.106 0.00236 **
## demoEHR_DiseaseDuration 0.540 0.59020
## ms_dx_condensedProgressive MS -5.413 3.25e-07 ***
## ms_dx_condensedMS, Subtype Not Specified -0.447 0.65564
## race_ethnicity_cleanAsian -1.827 0.07021 .
## race_ethnicity_cleanBlack Or African American -4.198 5.34e-05 ***
## race_ethnicity_cleanHispanic or Latino -1.409 0.16162
## race_ethnicity_cleanOther/Unknown/Declined -0.430 0.66775
## clean_sexMale 0.953 0.34261
## clean_sexNon-Binary 0.391 0.69652
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) dEHR_A dEHR_D m__PMS m__SNS rc_t_A r__OAA r__HoL r__O/U
## demoEHR_Age -0.908
## dmEHR_DssDr 0.095 -0.404
## ms_dx_cnPMS 0.154 -0.215 -0.102
## ms_d_MS,SNS 0.097 -0.053 -0.166 0.095
## rc_thncty_A -0.339 0.235 0.040 -0.016 -0.003
## rc_thn_BOAA -0.181 0.086 0.015 0.029 0.015 0.130
## rc_thnc_HoL -0.276 0.203 -0.026 -0.042 0.029 0.170 0.127
## rc_th_O/U/D -0.381 0.255 0.025 0.043 -0.027 0.181 0.137 0.151
## clean_sexMl -0.219 0.083 0.031 -0.026 -0.165 0.003 0.039 -0.089 0.181
## cln_sxNn-Bn -0.079 -0.002 0.127 0.020 -0.022 0.058 0.047 0.042 0.069
## cln_sM
## demoEHR_Age
## dmEHR_DssDr
## ms_dx_cnPMS
## ms_d_MS,SNS
## rc_thncty_A
## rc_thn_BOAA
## rc_thnc_HoL
## rc_th_O/U/D
## clean_sexMl
## cln_sxNn-Bn 0.066
# Residuals vs. fitted values
hist(resid(fwVel_fw_multi_dem), main = "Residuals All Demographic and MS Info")
# Normality check
qqnorm(residuals(fwVel_fw_multi_dem), main = "Normal Q-Q plot: Residuals All Demographic and MS Info")
# tidy results
fwVel_fw_multi_dem_df <- tidy(fwVel_fw_multi_dem, conf.int = TRUE) %>%
mutate(R2_conditional = r2(fwVel_fw_multi_dem)$R2_conditional) %>%
mutate(R2_marginal = r2(fwVel_fw_multi_dem)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Demographics and MS Info")
fwVel_fw_multi_dem_df
## # A tibble: 13 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Int~ 207. 15.6 13.3 120. 2.45e-25 176.
## 2 fixed <NA> demo~ -0.959 0.309 -3.11 122. 2.36e- 3 -1.57
## 3 fixed <NA> demo~ 0.248 0.460 0.540 116. 5.90e- 1 -0.663
## 4 fixed <NA> ms_d~ -49.3 9.11 -5.41 119. 3.25e- 7 -67.4
## 5 fixed <NA> ms_d~ -16.7 37.4 -0.447 128. 6.56e- 1 -90.8
## 6 fixed <NA> race~ -22.3 12.2 -1.83 116. 7.02e- 2 -46.6
## 7 fixed <NA> race~ -51.8 12.3 -4.20 114. 5.34e- 5 -76.2
## 8 fixed <NA> race~ -15.6 11.1 -1.41 115. 1.62e- 1 -37.6
## 9 fixed <NA> race~ -5.43 12.6 -0.430 119. 6.68e- 1 -30.4
## 10 fixed <NA> clea~ 7.11 7.46 0.953 115. 3.43e- 1 -7.67
## 11 fixed <NA> clea~ 13.2 33.7 0.391 92.6 6.97e- 1 -53.7
## 12 ran_pars bw_id sd__~ 29.8 NA NA NA NA NA
## 13 ran_pars Residual sd__~ 20.0 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
fwVel_fw_multi_vid_unadj <- lmer(FW_velocitycmsecmean ~
stride_time_median_sec_pose_zv +
log_delta_pix_h_rel_median_pose_zv +
mean_cadence_step_per_min_pose_zv +
stride_width_median_cm_pose_zv +
(1|bw_id),
data = zeno_fw_clean_df)
summary(fwVel_fw_multi_vid_unadj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## FW_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv +
## mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv +
## (1 | bw_id)
## Data: zeno_fw_clean_df
##
## REML criterion at convergence: 1566.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.66419 -0.56234 -0.03055 0.60676 2.70777
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 70.41 8.391
## Residual 712.69 26.696
## Number of obs: 167, groups: bw_id, 125
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 252.3937 36.9259 161.9680 6.835
## stride_time_median_sec_pose_zv -80.0099 20.0418 161.9663 -3.992
## log_delta_pix_h_rel_median_pose_zv 31.9134 4.9230 159.9963 6.483
## mean_cadence_step_per_min_pose_zv 0.2693 0.1695 161.9959 1.589
## stride_width_median_cm_pose_zv -2.1013 0.8291 160.2338 -2.534
## Pr(>|t|)
## (Intercept) 1.58e-10 ***
## stride_time_median_sec_pose_zv 9.91e-05 ***
## log_delta_pix_h_rel_median_pose_zv 1.07e-09 ***
## mean_cadence_step_per_min_pose_zv 0.1141
## stride_width_median_cm_pose_zv 0.0122 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) strd_t____ l_____ m_____
## strd_tm____ -0.829
## lg_dl______ 0.054 0.237
## mn_cdn_____ -0.915 0.660 -0.170
## strd_wd____ -0.189 -0.074 0.220 -0.026
# Residuals vs. fitted values
hist(resid(fwVel_fw_multi_vid_unadj), main = "Residuals All Video Metrics Unadjusted")
# Normality check
qqnorm(residuals(fwVel_fw_multi_vid_unadj), main = "Normal Q-Q plot: Residuals All Video Metrics Unadjusted")
# tidy results
fwVel_fw_multi_vid_unadj_df <- tidy(fwVel_fw_multi_vid_unadj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(fwVel_fw_multi_vid_unadj)$R2_conditional) %>%
mutate(R2_marginal = r2(fwVel_fw_multi_vid_unadj)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Video Metrics")
fwVel_fw_multi_vid_unadj_df
## # A tibble: 7 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inte~ 252. 36.9 6.84 162. 1.58e-10 1.79e+2
## 2 fixed <NA> strid~ -80.0 20.0 -3.99 162. 9.91e- 5 -1.20e+2
## 3 fixed <NA> log_d~ 31.9 4.92 6.48 160. 1.07e- 9 2.22e+1
## 4 fixed <NA> mean_~ 0.269 0.170 1.59 162. 1.14e- 1 -6.55e-2
## 5 fixed <NA> strid~ -2.10 0.829 -2.53 160. 1.22e- 2 -3.74e+0
## 6 ran_pars bw_id sd__(~ 8.39 NA NA NA NA NA
## 7 ran_pars Residual sd__O~ 26.7 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
fwVel_fw_multi_vid_adj <- lmer(FW_velocitycmsecmean ~
stride_time_median_sec_pose_zv +
log_delta_pix_h_rel_median_pose_zv +
mean_cadence_step_per_min_pose_zv +
stride_width_median_cm_pose_zv +
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = zeno_fw_clean_df)
## boundary (singular) fit: see help('isSingular')
summary(fwVel_fw_multi_vid_adj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## FW_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv +
## mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv +
## demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: zeno_fw_clean_df
##
## REML criterion at convergence: 1470.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3491 -0.5524 0.0191 0.5929 2.5253
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 1.757e-13 4.192e-07
## Residual 6.154e+02 2.481e+01
## Number of obs: 167, groups: bw_id, 125
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 279.05497 34.97490 152.00000
## stride_time_median_sec_pose_zv -70.43068 18.30922 152.00000
## log_delta_pix_h_rel_median_pose_zv 26.43804 4.59993 152.00000
## mean_cadence_step_per_min_pose_zv 0.30823 0.15484 152.00000
## stride_width_median_cm_pose_zv -1.77231 0.78927 152.00000
## demoEHR_Age -0.94283 0.20187 152.00000
## demoEHR_DiseaseDuration 0.09378 0.28616 152.00000
## ms_dx_condensedProgressive MS -9.57995 6.43577 152.00000
## ms_dx_condensedMS, Subtype Not Specified -21.09913 25.73336 152.00000
## race_ethnicity_cleanAsian -10.01438 7.78829 152.00000
## race_ethnicity_cleanBlack Or African American -31.79119 7.89517 152.00000
## race_ethnicity_cleanHispanic or Latino -10.52545 7.04757 152.00000
## race_ethnicity_cleanOther/Unknown/Declined -6.10940 8.14599 152.00000
## clean_sexMale 8.29111 4.72665 152.00000
## clean_sexNon-Binary 9.88749 18.06623 152.00000
## t value Pr(>|t|)
## (Intercept) 7.979 3.33e-13 ***
## stride_time_median_sec_pose_zv -3.847 0.000176 ***
## log_delta_pix_h_rel_median_pose_zv 5.747 4.80e-08 ***
## mean_cadence_step_per_min_pose_zv 1.991 0.048323 *
## stride_width_median_cm_pose_zv -2.246 0.026178 *
## demoEHR_Age -4.671 6.56e-06 ***
## demoEHR_DiseaseDuration 0.328 0.743569
## ms_dx_condensedProgressive MS -1.489 0.138678
## ms_dx_condensedMS, Subtype Not Specified -0.820 0.413549
## race_ethnicity_cleanAsian -1.286 0.200459
## race_ethnicity_cleanBlack Or African American -4.027 8.90e-05 ***
## race_ethnicity_cleanHispanic or Latino -1.493 0.137383
## race_ethnicity_cleanOther/Unknown/Declined -0.750 0.454421
## clean_sexMale 1.754 0.081426 .
## clean_sexNon-Binary 0.547 0.584981
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation matrix not shown by default, as p = 15 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# Residuals vs. fitted values
hist(resid(fwVel_fw_multi_vid_adj), main = "Residuals All Video Metrics Adjusted")
# Normality check
qqnorm(residuals(fwVel_fw_multi_vid_adj), main = "Normal Q-Q plot: Residuals All Video Metrics Adjusted")
# tidy results
fwVel_fw_multi_vid_adj_df <- tidy(fwVel_fw_multi_vid_adj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(fwVel_fw_multi_vid_adj)$R2_conditional) %>%
mutate(R2_marginal = r2(fwVel_fw_multi_vid_adj)$R2_marginal) %>%
mutate(Model = "Adjusted - Multivariate Video Metrics")
## Random effect variances not available. Returned R2 does not account for random effects.
## Warning: There was 1 warning in `mutate()`.
## i In argument: `R2_conditional = r2(fwVel_fw_multi_vid_adj)$R2_conditional`.
## Caused by warning:
## ! Can't compute random effect variances. Some variance components equal
## zero. Your model may suffer from singularity (see `?lme4::isSingular`
## and `?performance::check_singularity`).
## Solution: Respecify random structure! You may also decrease the
## `tolerance` level to enforce the calculation of random effect variances.
## Random effect variances not available. Returned R2 does not account for random effects.
## Warning: There was 1 warning in `mutate()`.
## i In argument: `R2_marginal = r2(fwVel_fw_multi_vid_adj)$R2_marginal`.
## Caused by warning:
## ! Can't compute random effect variances. Some variance components equal
## zero. Your model may suffer from singularity (see `?lme4::isSingular`
## and `?performance::check_singularity`).
## Solution: Respecify random structure! You may also decrease the
## `tolerance` level to enforce the calculation of random effect variances.
fwVel_fw_multi_vid_adj
## Linear mixed model fit by REML ['lmerModLmerTest']
## Formula:
## FW_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv +
## mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv +
## demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: zeno_fw_clean_df
## REML criterion at convergence: 1470.291
## Random effects:
## Groups Name Std.Dev.
## bw_id (Intercept) 4.192e-07
## Residual 2.481e+01
## Number of obs: 167, groups: bw_id, 125
## Fixed Effects:
## (Intercept)
## 279.05497
## stride_time_median_sec_pose_zv
## -70.43068
## log_delta_pix_h_rel_median_pose_zv
## 26.43804
## mean_cadence_step_per_min_pose_zv
## 0.30823
## stride_width_median_cm_pose_zv
## -1.77231
## demoEHR_Age
## -0.94283
## demoEHR_DiseaseDuration
## 0.09378
## ms_dx_condensedProgressive MS
## -9.57995
## ms_dx_condensedMS, Subtype Not Specified
## -21.09913
## race_ethnicity_cleanAsian
## -10.01438
## race_ethnicity_cleanBlack Or African American
## -31.79119
## race_ethnicity_cleanHispanic or Latino
## -10.52545
## race_ethnicity_cleanOther/Unknown/Declined
## -6.10940
## clean_sexMale
## 8.29111
## clean_sexNon-Binary
## 9.88749
## optimizer (nloptwrap) convergence code: 0 (OK) ; 0 optimizer warnings; 1 lme4 warnings
p value < 0.05, more complex model is significantly better than the simpler model
https://bookdown.org/ndphillips/YaRrr/comparing-regression-models-with-anova.html
# Demographics only vs Video + Demographics
anova(fwVel_fw_multi_dem, fwVel_fw_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: zeno_fw_clean_df
## Models:
## fwVel_fw_multi_dem: FW_velocitycmsecmean ~ demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## fwVel_fw_multi_vid_adj: FW_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## fwVel_fw_multi_dem 13 1657.2 1697.7 -815.57 1631.2
## fwVel_fw_multi_vid_adj 17 1564.7 1617.8 -765.37 1530.7 100.41 4 < 2.2e-16
##
## fwVel_fw_multi_dem
## fwVel_fw_multi_vid_adj ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Video only vs Video + Demographics
anova(fwVel_fw_multi_vid_unadj, fwVel_fw_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: zeno_fw_clean_df
## Models:
## fwVel_fw_multi_vid_unadj: FW_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + (1 | bw_id)
## fwVel_fw_multi_vid_adj: FW_velocitycmsecmean ~ stride_time_median_sec_pose_zv + log_delta_pix_h_rel_median_pose_zv + mean_cadence_step_per_min_pose_zv + stride_width_median_cm_pose_zv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## fwVel_fw_multi_vid_unadj 7 1595.3 1617.1 -790.63 1581.3
## fwVel_fw_multi_vid_adj 17 1564.7 1617.8 -765.37 1530.7 50.518 10
## Pr(>Chisq)
## fwVel_fw_multi_vid_unadj
## fwVel_fw_multi_vid_adj 2.143e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
fwVel_fw_multivar_all <- bind_rows(fwVel_fw_multi_dem_df,
fwVel_fw_multi_vid_unadj_df,
fwVel_fw_multi_vid_adj_df)
# save R-squared
adj_r_squared_df <- fwVel_fw_multivar_all[c('Model', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 3 x 3
## Model R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Unadjusted - Multivariate Demographics and MS Info 0.8 0.34
## 2 Unadjusted - Multivariate Video Metrics 0.61 0.57
## 3 Adjusted - Multivariate Video Metrics NA 0.68
write.csv(adj_r_squared_df, file.path(output_dir, 'ZenoVelFw_adj_vs_unadj_fw_r2.csv'))
p <- adj_vs_unadj_plot(results_df = fwVel_fw_multivar_all,
plot_title = "FW: FW Mat Velocity Unadjusted vs Adjusted",
x_adj = 30)
p
ggsave(file.path(output_dir, 'ZenoVelFw_adj_vs_unadj_fw_estimates.png'),
bg = "white", width= 12, height=10)
uni_home_pwsvel <- all_univariate_mixed_effect(data = home_df,
outcome_column = "PWS_velocitycmsecmean")
## [1] "log_delta_pix_h_rel_median_pose"
## Warning: Removed 4 rows containing missing values (`geom_point()`).
## PWS_velocitycmsecmean ~ log_delta_pix_h_rel_median_pose + (1 |
## bw_id)
## <environment: 0x000000002bd373e0>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula1
## Data: data
##
## REML criterion at convergence: 496.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.90621 -0.16387 0.00884 0.19968 2.10253
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 716.88 26.775
## Residual 45.42 6.739
## Number of obs: 61, groups: bw_id, 30
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 114.284 7.485 57.928 15.268 <2e-16
## log_delta_pix_h_rel_median_pose 7.948 4.072 42.752 1.952 0.0575
##
## (Intercept) ***
## log_delta_pix_h_rel_median_pose .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## lg_dlt_____ 0.747
## [1] "stride_time_median_sec_pose"
## Warning: Removed 13 rows containing missing values (`geom_point()`).
## PWS_velocitycmsecmean ~ stride_time_median_sec_pose + (1 | bw_id)
## <environment: 0x000000002bd373e0>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula2
## Data: data
##
## REML criterion at convergence: 415.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.90371 -0.21074 -0.03452 0.23932 1.74292
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 676.38 26.007
## Residual 51.32 7.164
## Number of obs: 52, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 143.96 18.89 48.36 7.620 7.93e-10 ***
## stride_time_median_sec_pose -33.91 15.13 49.65 -2.241 0.0295 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_tm_m__ -0.956
## [1] "mean_cadence_step_per_min_pose"
## Warning: Removed 12 rows containing missing values (`geom_point()`).
## PWS_velocitycmsecmean ~ mean_cadence_step_per_min_pose + (1 |
## bw_id)
## <environment: 0x000000002bd373e0>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula3
## Data: data
##
## REML criterion at convergence: 435.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.05653 -0.16339 -0.03195 0.14299 1.90666
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 873.41 29.553
## Residual 46.75 6.838
## Number of obs: 53, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 97.43456 10.93683 49.90227 8.909 6.88e-12
## mean_cadence_step_per_min_pose 0.05897 0.08724 31.74739 0.676 0.504
##
## (Intercept) ***
## mean_cadence_step_per_min_pose
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mn_cdnc____ -0.821
## [1] "stride_width_median_cm_pose"
## Warning: Removed 12 rows containing missing values (`geom_point()`).
## PWS_velocitycmsecmean ~ stride_width_median_cm_pose + (1 | bw_id)
## <environment: 0x000000002bd373e0>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula4
## Data: data
##
## REML criterion at convergence: 431.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.84421 -0.16481 -0.00374 0.14024 1.93040
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 857.19 29.278
## Residual 47.37 6.883
## Number of obs: 53, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 109.3423 10.4335 50.7638 10.480 2.7e-14 ***
## stride_width_median_cm_pose -0.4419 0.6362 32.8090 -0.695 0.492
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## strd_wdt___ -0.805
## [1] "demoEHR_Age"
## PWS_velocitycmsecmean ~ demoEHR_Age + (1 | bw_id)
## <environment: 0x000000002bd373e0>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula5
## Data: data
##
## REML criterion at convergence: 531.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.98313 -0.11763 -0.00876 0.11198 1.96658
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 803.57 28.347
## Residual 39.97 6.322
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 125.9571 21.9630 28.9270 5.735 3.33e-06 ***
## demoEHR_Age -0.4478 0.4101 28.9367 -1.092 0.284
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## demoEHR_Age -0.972
## [1] "demoEHR_DiseaseDuration"
## PWS_velocitycmsecmean ~ demoEHR_DiseaseDuration + (1 | bw_id)
## <environment: 0x000000002bd373e0>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula6
## Data: data
##
## REML criterion at convergence: 531
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.94378 -0.11440 -0.01186 0.11874 1.99432
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 776.52 27.87
## Residual 41.34 6.43
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 109.8340 8.6367 29.2876 12.717 1.88e-13 ***
## demoEHR_DiseaseDuration -0.6491 0.6308 29.5686 -1.029 0.312
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## dmEHR_DssDr -0.809
## [1] "ms_dx_condensed"
## PWS_velocitycmsecmean ~ ms_dx_condensed + (1 | bw_id)
## <environment: 0x000000002bd373e0>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula7
## Data: data
##
## REML criterion at convergence: 510.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.97230 -0.13529 -0.00839 0.13676 1.97131
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 664.14 25.771
## Residual 40.09 6.332
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 107.128 5.345 27.847 20.041
## ms_dx_condensedProgressive MS -34.072 12.892 28.008 -2.643
## ms_dx_condensedMS, Subtype Not Specified 15.441 19.253 27.738 0.802
## Pr(>|t|)
## (Intercept) <2e-16 ***
## ms_dx_condensedProgressive MS 0.0133 *
## ms_dx_condensedMS, Subtype Not Specified 0.4294
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) m__PMS
## ms_dx_cnPMS -0.415
## ms_d_MS,SNS -0.278 0.115
## [1] "race_ethnicity_clean"
## PWS_velocitycmsecmean ~ race_ethnicity_clean + (1 | bw_id)
## <environment: 0x000000002bd373e0>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula8
## Data: data
##
## REML criterion at convergence: 494.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9647 -0.1263 0.0000 0.1302 1.9849
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 744.65 27.288
## Residual 39.97 6.322
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 102.090 5.653 26.096
## race_ethnicity_cleanAsian 24.486 20.354 25.951
## race_ethnicity_cleanBlack Or African American -54.617 28.224 25.945
## race_ethnicity_cleanHispanic or Latino -16.830 28.224 25.945
## race_ethnicity_cleanOther/Unknown/Declined 13.212 16.934 25.925
## t value Pr(>|t|)
## (Intercept) 18.058 2.87e-16 ***
## race_ethnicity_cleanAsian 1.203 0.2398
## race_ethnicity_cleanBlack Or African American -1.935 0.0639 .
## race_ethnicity_cleanHispanic or Latino -0.596 0.5561
## race_ethnicity_cleanOther/Unknown/Declined 0.780 0.4423
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rc_t_A r__OAA r__HoL
## rc_thncty_A -0.278
## rc_thn_BOAA -0.200 0.056
## rc_thnc_HoL -0.200 0.056 0.040
## rc_th_O/U/D -0.334 0.093 0.067 0.067
## [1] "clean_sex"
## PWS_velocitycmsecmean ~ clean_sex + (1 | bw_id)
## <environment: 0x000000002bd373e0>
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: formula9
## Data: data
##
## REML criterion at convergence: 513.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.95533 -0.11451 -0.00159 0.08492 1.99707
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 745.49 27.304
## Residual 39.91 6.318
## Number of obs: 65, groups: bw_id, 31
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 96.934 5.653 28.148 17.147 <2e-16 ***
## clean_sexMale 25.176 12.652 28.249 1.990 0.0564 .
## clean_sexNon-Binary 26.202 28.238 28.046 0.928 0.3614
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) cln_sM
## clean_sexMl -0.447
## cln_sxNn-Bn -0.200 0.089
# save adjusted r_squared
adj_r_squared_df <- uni_home_pwsvel[c('Variable', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 9 x 3
## Variable R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Log Pixel Height Proxy 0.94 0.02
## 2 Stride Time - Median 0.94 0.09
## 3 Cadence - Mean 0.95 0
## 4 Stride Width - Median 0.95 0
## 5 Age 0.95 0.04
## 6 Disease Duration 0.95 0.03
## 7 MS DX 0.95 0.19
## 8 Race and Ethnicity 0.96 0.17
## 9 Sex 0.96 0.12
write.csv(adj_r_squared_df, file.path(output_dir, 'ZenoVelPws_univariate_home_r2.csv'))
# Plot estimates
p <- univariate_regression_plot(results = uni_home_pwsvel,
plot_title = "Home Univariate - lmer(Zeno Mat Velocity ~ Predictor + (1 | bw_id))",
x_adj = 15)
p
ggsave(file.path(output_dir, 'ZenoVelPws_univariate_home_estimates.png'),
bg = "white", width= 10, height=10)
pwsVel_home_multi_dem <- lmer(PWS_velocitycmsecmean ~
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = home_clean_df)
summary(pwsVel_home_multi_dem)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PWS_velocitycmsecmean ~ demoEHR_Age + demoEHR_DiseaseDuration +
## ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: home_clean_df
##
## REML criterion at convergence: 352.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7683 -0.1725 0.0000 0.1119 1.8031
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 441.67 21.016
## Residual 48.88 6.992
## Number of obs: 51, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 99.0207 25.2296 13.2978 3.925
## demoEHR_Age 0.1069 0.4896 13.5368 0.218
## demoEHR_DiseaseDuration -0.0466 0.7218 14.1702 -0.065
## ms_dx_condensedProgressive MS -51.8764 12.8508 13.3888 -4.037
## ms_dx_condensedMS, Subtype Not Specified 3.8403 18.6430 13.4083 0.206
## race_ethnicity_cleanAsian 35.9656 24.3295 13.3002 1.478
## race_ethnicity_cleanHispanic or Latino -19.8172 25.1813 13.4368 -0.787
## race_ethnicity_cleanOther/Unknown/Declined 12.5805 16.1394 13.4907 0.779
## clean_sexMale 26.6643 12.8470 13.7155 2.076
## Pr(>|t|)
## (Intercept) 0.00167 **
## demoEHR_Age 0.83045
## demoEHR_DiseaseDuration 0.94942
## ms_dx_condensedProgressive MS 0.00133 **
## ms_dx_condensedMS, Subtype Not Specified 0.83989
## race_ethnicity_cleanAsian 0.16262
## race_ethnicity_cleanHispanic or Latino 0.44495
## race_ethnicity_cleanOther/Unknown/Declined 0.44915
## clean_sexMale 0.05725 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) dEHR_A dEHR_D m__PMS m__SNS rc_t_A r__HoL r__O/U
## demoEHR_Age -0.936
## dmEHR_DssDr 0.239 -0.467
## ms_dx_cnPMS 0.089 -0.187 -0.048
## ms_d_MS,SNS 0.307 -0.328 -0.104 0.269
## rc_thncty_A -0.425 0.342 -0.047 0.041 -0.082
## rc_thnc_HoL 0.057 -0.037 -0.368 0.194 0.204 0.009
## rc_th_O/U/D -0.522 0.460 -0.311 0.118 -0.017 0.263 0.147
## clean_sexMl -0.487 0.427 -0.257 -0.072 -0.263 0.244 0.115 0.363
# Residuals vs. fitted values
hist(resid(pwsVel_home_multi_dem), main = "Residuals All Demographic and MS Info")
# Normality check
qqnorm(residuals(pwsVel_home_multi_dem), main = "Normal Q-Q plot: Residuals All Demographic and MS Info")
# tidy results
pwsVel_home_multi_dem_df <- tidy(pwsVel_home_multi_dem, conf.int = TRUE) %>%
mutate(R2_conditional = r2(pwsVel_home_multi_dem)$R2_conditional) %>%
mutate(R2_marginal = r2(pwsVel_home_multi_dem)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Demographics and MS Info")
pwsVel_home_multi_dem_df
## # A tibble: 11 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inte~ 99.0 25.2 3.92 13.3 0.00167 44.6
## 2 fixed <NA> demoE~ 0.107 0.490 0.218 13.5 0.830 -0.947
## 3 fixed <NA> demoE~ -0.0466 0.722 -0.0646 14.2 0.949 -1.59
## 4 fixed <NA> ms_dx~ -51.9 12.9 -4.04 13.4 0.00133 -79.6
## 5 fixed <NA> ms_dx~ 3.84 18.6 0.206 13.4 0.840 -36.3
## 6 fixed <NA> race_~ 36.0 24.3 1.48 13.3 0.163 -16.5
## 7 fixed <NA> race_~ -19.8 25.2 -0.787 13.4 0.445 -74.0
## 8 fixed <NA> race_~ 12.6 16.1 0.779 13.5 0.449 -22.2
## 9 fixed <NA> clean~ 26.7 12.8 2.08 13.7 0.0572 -0.944
## 10 ran_pars bw_id sd__(~ 21.0 NA NA NA NA NA
## 11 ran_pars Residual sd__O~ 6.99 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
pwsVel_home_multi_vid_unadj <- lmer(PWS_velocitycmsecmean ~
stride_time_median_sec_pose_hv +
log_delta_pix_h_rel_median_pose_hv +
mean_cadence_step_per_min_pose_hv +
stride_width_median_cm_pose_hv +
(1|bw_id),
data = home_clean_df)
summary(pwsVel_home_multi_vid_unadj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## PWS_velocitycmsecmean ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv +
## mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv +
## (1 | bw_id)
## Data: home_clean_df
##
## REML criterion at convergence: 401.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.55618 -0.31475 -0.00102 0.29833 1.66387
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 596.41 24.422
## Residual 59.27 7.699
## Number of obs: 51, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 152.00146 28.64681 42.18052 5.306
## stride_time_median_sec_pose_hv -31.52061 16.94354 45.99499 -1.860
## log_delta_pix_h_rel_median_pose_hv 7.55781 6.80844 30.47481 1.110
## mean_cadence_step_per_min_pose_hv 0.02949 0.11984 26.49102 0.246
## stride_width_median_cm_pose_hv -0.36259 0.87149 33.96509 -0.416
## Pr(>|t|)
## (Intercept) 3.88e-06 ***
## stride_time_median_sec_pose_hv 0.0692 .
## log_delta_pix_h_rel_median_pose_hv 0.2757
## mean_cadence_step_per_min_pose_hv 0.8075
## stride_width_median_cm_pose_hv 0.6800
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) strd_t____ l_____ m_____
## strd_tm____ -0.820
## lg_dl______ -0.110 0.306
## mn_cdn_____ -0.623 0.276 -0.079
## strd_wd____ -0.362 0.201 0.528 -0.079
# Residuals vs. fitted values
hist(resid(pwsVel_home_multi_vid_unadj), main = "Residuals All Video Metrics Unadjusted")
# Normality check
qqnorm(residuals(pwsVel_home_multi_vid_unadj), main = "Normal Q-Q plot: Residuals All Video Metrics Unadjusted")
# tidy results
pwsVel_home_multi_vid_unadj_df <- tidy(pwsVel_home_multi_vid_unadj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(pwsVel_home_multi_vid_unadj)$R2_conditional) %>%
mutate(R2_marginal = r2(pwsVel_home_multi_vid_unadj)$R2_marginal) %>%
mutate(Model = "Unadjusted - Multivariate Video Metrics")
pwsVel_home_multi_vid_unadj_df
## # A tibble: 7 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inter~ 152. 28.6 5.31 42.2 3.88e-6 94.2
## 2 fixed <NA> stride~ -31.5 16.9 -1.86 46.0 6.92e-2 -65.6
## 3 fixed <NA> log_de~ 7.56 6.81 1.11 30.5 2.76e-1 -6.34
## 4 fixed <NA> mean_c~ 0.0295 0.120 0.246 26.5 8.08e-1 -0.217
## 5 fixed <NA> stride~ -0.363 0.871 -0.416 34.0 6.80e-1 -2.13
## 6 ran_pars bw_id sd__(I~ 24.4 NA NA NA NA NA
## 7 ran_pars Residual sd__Ob~ 7.70 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
pwsVel_home_multi_vid_adj <- lmer(PWS_velocitycmsecmean ~
stride_time_median_sec_pose_hv +
log_delta_pix_h_rel_median_pose_hv +
mean_cadence_step_per_min_pose_hv +
stride_width_median_cm_pose_hv +
demoEHR_Age +
demoEHR_DiseaseDuration +
ms_dx_condensed +
race_ethnicity_clean +
clean_sex +
(1|bw_id),
data = home_clean_df)
summary(pwsVel_home_multi_vid_adj)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## PWS_velocitycmsecmean ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv +
## mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv +
## demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed +
## race_ethnicity_clean + clean_sex + (1 | bw_id)
## Data: home_clean_df
##
## REML criterion at convergence: 339
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.72579 -0.20156 0.00372 0.16820 1.96033
##
## Random effects:
## Groups Name Variance Std.Dev.
## bw_id (Intercept) 429.17 20.716
## Residual 54.33 7.371
## Number of obs: 51, groups: bw_id, 23
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 104.167004 40.693556 32.401756
## stride_time_median_sec_pose_hv 0.492992 19.222242 37.800828
## log_delta_pix_h_rel_median_pose_hv 7.279419 6.603662 30.513459
## mean_cadence_step_per_min_pose_hv -0.009213 0.114462 28.674694
## stride_width_median_cm_pose_hv 0.157705 0.872278 31.865658
## demoEHR_Age 0.157894 0.493513 13.565744
## demoEHR_DiseaseDuration -0.140464 0.724737 14.202897
## ms_dx_condensedProgressive MS -48.717374 16.734043 23.234867
## ms_dx_condensedMS, Subtype Not Specified 2.408856 19.256910 14.386728
## race_ethnicity_cleanAsian 36.669986 24.223712 12.967084
## race_ethnicity_cleanHispanic or Latino -20.397090 25.171045 13.245653
## race_ethnicity_cleanOther/Unknown/Declined 13.467405 16.027845 13.040109
## clean_sexMale 25.362494 13.086548 14.385849
## t value Pr(>|t|)
## (Intercept) 2.560 0.01533 *
## stride_time_median_sec_pose_hv 0.026 0.97967
## log_delta_pix_h_rel_median_pose_hv 1.102 0.27894
## mean_cadence_step_per_min_pose_hv -0.080 0.93641
## stride_width_median_cm_pose_hv 0.181 0.85767
## demoEHR_Age 0.320 0.75389
## demoEHR_DiseaseDuration -0.194 0.84907
## ms_dx_condensedProgressive MS -2.911 0.00781 **
## ms_dx_condensedMS, Subtype Not Specified 0.125 0.90218
## race_ethnicity_cleanAsian 1.514 0.15406
## race_ethnicity_cleanHispanic or Latino -0.810 0.43206
## race_ethnicity_cleanOther/Unknown/Declined 0.840 0.41591
## clean_sexMale 1.938 0.07250 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation matrix not shown by default, as p = 13 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
# Residuals vs. fitted values
hist(resid(pwsVel_home_multi_vid_adj), main = "Residuals All Video Metrics Adjusted")
# Normality check
qqnorm(residuals(pwsVel_home_multi_vid_adj), main = "Normal Q-Q plot: Residuals All Video Metrics Adjusted")
# tidy results
pwsVel_home_multi_vid_adj_df <- tidy(pwsVel_home_multi_vid_adj, conf.int = TRUE) %>%
mutate(R2_conditional = r2(pwsVel_home_multi_vid_adj)$R2_conditional) %>%
mutate(R2_marginal = r2(pwsVel_home_multi_vid_adj)$R2_marginal) %>%
mutate(Model = "Adjusted - Multivariate Video Metrics")
pwsVel_home_multi_vid_adj_df
## # A tibble: 15 x 13
## effect group term estimate std.error statistic df p.value conf.low
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Inte~ 1.04e+2 40.7 2.56 32.4 0.0153 21.3
## 2 fixed <NA> strid~ 4.93e-1 19.2 0.0256 37.8 0.980 -38.4
## 3 fixed <NA> log_d~ 7.28e+0 6.60 1.10 30.5 0.279 -6.20
## 4 fixed <NA> mean_~ -9.21e-3 0.114 -0.0805 28.7 0.936 -0.243
## 5 fixed <NA> strid~ 1.58e-1 0.872 0.181 31.9 0.858 -1.62
## 6 fixed <NA> demoE~ 1.58e-1 0.494 0.320 13.6 0.754 -0.904
## 7 fixed <NA> demoE~ -1.40e-1 0.725 -0.194 14.2 0.849 -1.69
## 8 fixed <NA> ms_dx~ -4.87e+1 16.7 -2.91 23.2 0.00781 -83.3
## 9 fixed <NA> ms_dx~ 2.41e+0 19.3 0.125 14.4 0.902 -38.8
## 10 fixed <NA> race_~ 3.67e+1 24.2 1.51 13.0 0.154 -15.7
## 11 fixed <NA> race_~ -2.04e+1 25.2 -0.810 13.2 0.432 -74.7
## 12 fixed <NA> race_~ 1.35e+1 16.0 0.840 13.0 0.416 -21.1
## 13 fixed <NA> clean~ 2.54e+1 13.1 1.94 14.4 0.0725 -2.63
## 14 ran_pars bw_id sd__(~ 2.07e+1 NA NA NA NA NA
## 15 ran_pars Residual sd__O~ 7.37e+0 NA NA NA NA NA
## # i 4 more variables: conf.high <dbl>, R2_conditional <dbl>, R2_marginal <dbl>,
## # Model <chr>
p value < 0.05, more complex model is significantly better than the simpler model
https://bookdown.org/ndphillips/YaRrr/comparing-regression-models-with-anova.html
# Demographics only vs Video + Demographics
anova(pwsVel_home_multi_dem, pwsVel_home_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: home_clean_df
## Models:
## pwsVel_home_multi_dem: PWS_velocitycmsecmean ~ demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## pwsVel_home_multi_vid_adj: PWS_velocitycmsecmean ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv + mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## pwsVel_home_multi_dem 11 422.14 443.39 -200.07 400.14
## pwsVel_home_multi_vid_adj 15 427.92 456.90 -198.96 397.92 2.2177 4
## Pr(>Chisq)
## pwsVel_home_multi_dem
## pwsVel_home_multi_vid_adj 0.6958
# Video only vs Video + Demographics
anova(pwsVel_home_multi_vid_unadj, pwsVel_home_multi_vid_adj)
## refitting model(s) with ML (instead of REML)
## Data: home_clean_df
## Models:
## pwsVel_home_multi_vid_unadj: PWS_velocitycmsecmean ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv + mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv + (1 | bw_id)
## pwsVel_home_multi_vid_adj: PWS_velocitycmsecmean ~ stride_time_median_sec_pose_hv + log_delta_pix_h_rel_median_pose_hv + mean_cadence_step_per_min_pose_hv + stride_width_median_cm_pose_hv + demoEHR_Age + demoEHR_DiseaseDuration + ms_dx_condensed + race_ethnicity_clean + clean_sex + (1 | bw_id)
## npar AIC BIC logLik deviance Chisq Df
## pwsVel_home_multi_vid_unadj 7 432.55 446.07 -209.27 418.55
## pwsVel_home_multi_vid_adj 15 427.92 456.90 -198.96 397.92 20.623 8
## Pr(>Chisq)
## pwsVel_home_multi_vid_unadj
## pwsVel_home_multi_vid_adj 0.00822 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pwsVel_home_multivar_all <- bind_rows(pwsVel_home_multi_dem_df,
pwsVel_home_multi_vid_unadj_df,
pwsVel_home_multi_vid_adj_df)
# save R-squared
adj_r_squared_df <- pwsVel_home_multivar_all[c('Model', 'R2_conditional', 'R2_marginal')] %>%
distinct() %>% # remove duplicates
mutate(R2_conditional = round(R2_conditional, 2)) %>%
mutate(R2_marginal = round(R2_marginal, 2))
print(adj_r_squared_df)
## # A tibble: 3 x 3
## Model R2_conditional R2_marginal
## <chr> <dbl> <dbl>
## 1 Unadjusted - Multivariate Demographics and MS Info 0.95 0.52
## 2 Unadjusted - Multivariate Video Metrics 0.92 0.15
## 3 Adjusted - Multivariate Video Metrics 0.95 0.53
write.csv(adj_r_squared_df, file.path(output_dir, 'ZenoVelPws_adj_vs_unadj_home_r2.csv'))
p <- adj_vs_unadj_plot(results_df = pwsVel_home_multivar_all,
plot_title = "Home: PWS Mat Velocity Unadjusted vs Adjusted",
x_adj = 30)
p
ggsave(file.path(output_dir, 'ZenoVelPws_adj_vs_unadj_home_estimates.png'),
bg = "white", width= 12, height=10)